I'm trying to transcribe local audio files in my app.
Short files recognised fine, but if audio is more than about 15 min it is not. Console immediately shows this error:
2020-01-17 12:57:07.528986+0300 App[2816:791131] [Utility]
+[AFAggregator logDictationFailedWithError:] Error Domain=kAFAssistantErrorDomain Code=1107 "(null)"
This is my code:
let localRecognitionRequest = SFSpeechURLRecognitionRequest(url: fileUrl)
localRecognitionRequest.shouldReportPartialResults = false
if speechRecognizer.supportsOnDeviceRecognition {
localRecognitionRequest.requiresOnDeviceRecognition = true
}
recognitionTask = speechRecognizer.recognitionTask(with: localRecognitionRequest, delegate: self)
And when there is an error, only one delegate method fires:
func speechRecognitionTask(_ task: SFSpeechRecognitionTask, didFinishSuccessfully successfully: Bool) { }
with successfully = false
I have Xcode 11.3.1
Trying only on device - iPhone XS (iOS 13.3)
Have anyone faced this problem?
I was also seeing error code 1107 and as strange as this sounds, a Simulator reset fixed it for me.
While the simulator is selected:
Go to the top Menu
Select Device
Click on Erase All Content and Settings...
(Optional) Kill XCode and relaunch
This did the trick.
Related
I am a beginning Swift developer who inherited a macOS app that does screen and microphone recording.
At one point this app would prompt a new user to grant Microphone and Screen Recording permissions as soon as those activities were initiated. I received reports that a new version that I built was not prompting for microphone permissions. I did some testing on my own system and now am having those same issues where audio and screen recording activities do not prompt for screen recording.
I have tried various combinations of the tccutil command to reset individual and all existing permissions. I've deleted and reinstalled the app numerous times and, I've rebooted numerous times and even cleared SMC but nothing seems to help.
Here is a snippet of code that I am using to start audio recording:
let settings = [
AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
AVSampleRateKey: 16000,
AVNumberOfChannelsKey: 1,
AVEncoderAudioQualityKey: AVAudioQuality.min.rawValue
]
_recorder = try AVAudioRecorder(url: url, settings: settings)
_recorder?.record()
And here is the code used to take a screen shot of a window:
static func generate(forWindow window: [String: AnyObject], mask windowMask: Bool) -> (image: CGImage?, window: CGRect)? {
let windowId = (window[kCGWindowNumber as String] as! NSNumber).int32Value
let rect = windowRect(forWindow: window)
let option = windowMask ? CGWindowListOption(arrayLiteral: .optionIncludingWindow) : CGWindowListOption(arrayLiteral: [.optionIncludingWindow, .optionOnScreenAboveWindow])
var image = CGWindowListCreateImage(rect, option, CGWindowID(windowId), .nominalResolution)
if image != nil {
image = resize(image!)
}
return (image, rect)
}
I am building with Xcode 12.3 and using Swift 4 -- I am not able to upgrade to Swift 5 at this point -- and am using Catalina 10.15.7.
As mentioned, I am new to Swift development and have exhausted all of my options. Is there any additional information that I can provide to help get this resolved?
Recently i upgraded my mac to Catalina and seeing weird issues with NSAlert().
When ever any alert is opened i am getting bellow error in console and the alert is automatically closing, without any user clicking on OK button.
Error in console :
this class is not key value coding-compliant for the key modalWindow.' with user dictionary {
NSTargetObjectUserInfoKey = "<ProjectName.AppDelegate: 0x100b07400>";
NSUnknownUserInfoKey = modalWindow;
}
Below is my code for displaying Alert.
let myPopup: NSAlert = NSAlert()
myPopup.messageText = messageText
myPopup.informativeText = infoText
myPopup.alertStyle = NSAlert.Style.warning
myPopup.addButton(withTitle: NSLocalizedString("OK", comment: "Button Text"))
let res = myPopup.runModal()
FYI : This is Mac App, using swift, Xcode11 (tried with Xcode 11.1 & 11.2)
Finally figured it,
In my application we do support for scripting so i added below code in AppDelegate file :
func application(_ sender: NSApplication, delegateHandlesKey key: String) -> Bool {
return true
}
Since i am returning true always it is creating issues with NSOpenPanels, NSSavePanels and NSAlert, and i changed the code as below and it is working fine without any issues.
func application(_ sender: NSApplication, delegateHandlesKey key: String) -> Bool {
if key == "[.sdf file KEY HERE]"{
return true
}
return false
}
Please note i am getting this issues only in latest OS Catalina, in previous OS i didn't got any issues.
I am trying to port audio input to Mac Catalyst. As of now I am using xcode13GM, macOS 10.15 Beta 8 (19A558d), ios13beta8. The following code does not return any input ports.
let audioSession = AVAudioSession.sharedInstance()
try audioSession.setActive(true, options: .notifyOthersOnDeactivation)
var mic : AVAudioSessionPortDescription? = nil
for input in audioSession.availableInputs! {
if input.portType == AVAudioSession.Port.builtInMic {
mic = input
} else {
print("Not internal mic")
}
// here: 'mic' is nil
I have granted the "Hardend Runtime - Audio Input" entitlement and the app asks for microphone permission which is granted.
When accessing audioSession.availableInputs the following error shows up in the console:
[avas] AVAudioSession_MacOS.mm:258:-[AVAudioSession
getChannelsFromAU:PortName:PortID:]: ERROR in getting channel layout
for auScope 1768845428 element 1
Is this a bug due to beta status of the whole stuff or am I missing something ?
Thanks
I'm new on swift 4.
I'm trying to develop a simple mac program to get all music songs from iTunesLibrary. I did sign my code and import iTunesLibrary.framework to the project. But I get an error about iTlib XPC connection error:
2018-05-29 19:51:16.277312+0700 KODE[2325:47137] ITLib received
XPC_ERROR_CONNECTION_INTERRUPTED connection error (can be ignored).
2018-05-29 19:51:16.277410+0700 KODE[2325:47137] ITLib xpc error:
Connection interrupted
2018-05-29 19:51:16.277441+0700 KODE[2325:47072] Assertion failure:
status == noErr (100005)
Here is my code
override func viewDidLoad() {
super.viewDidLoad()
let library: ITLibrary
do {
library = try ITLibrary(apiVersion: "1.0")
} catch {
print("Error occured!")
return
}
let tracks = library.allMediaItems
for track in tracks {
print(track.album.title!)
}
// Do any additional setup after loading the view.
}
If you have a sandboxed app, go to Capabilites/"App Sandbox"/"File Access"/"Music Folder". Change "None" to "Read Only". It helped me. Also app must be properly signed.
As Parse crash report is depreciating, we are moving to Google Analytics.
I follow the guide to and receive view tracking and exception reports successfully.
here is how I setup the GA
// Configure tracker from GoogleService-Info.plist.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
// Optional: configure GAI options.
let gai = GAI.sharedInstance()
gai.trackerWithTrackingId("UA-XXXXXX-1")
gai.trackUncaughtExceptions = true // report uncaught exceptions
gai.dispatchInterval = 1
gai.defaultTracker.allowIDFACollection = true
#if DEBUG
gai.logger.logLevel = GAILogLevel.Verbose // remove before app release
#endif
And I tried to make a crash by (in AppDelegate.swift didFinishLaunchingWithOptions ):
delay(20.0) { () -> () in
let _ = [String]()[10];
}
And I can't get any crash report from GA dashboard.
I've tried to move this line to an IBAction, but failed.
My testing steps:
debug on device ->(20s)-> crash
debug on device 2nd time ->(20s)-> crash
run the app without debugging ->(20s)-> crash
run the app without debugging ->(20s)-> crash
It turns out that Google Analytics only supports reporting of uncaught Objective-C exceptions. It does not report Swift throws. The following creates a Swift throw (and is not reported by GA):
let crashArray:Array = [0]
crashArray[1]
The following does create an Objective-C exception and is reported by GA:
let array = NSArray()
let _ = array.objectAtIndex(99)
Some useful information here...
How should I use NSSetUncaughtExceptionHandler in Swift
We can force an Objective-C exception from within Swift by using the following command (i.e. from within a catch).
let error = NSError(domain: "Some error.", code: 0, userInfo: nil)
NSException.raise("Exception", format:"Error: %#", arguments:getVaList([error ?? "nil"]))
There is not a way I can find to automatically capture all throws and relay them as an Objective-C exception.