Post

Replies

Boosts

Views

Activity

Reply to Random crash from AVFAudio library
It seems I do get the same crash on my iOS code. I could not reproduce it, but get between 1 and 4 crashes from every 200 user sessions. Any hints on how to solve this issue would be highly appreciated. Here is my code (very similar to code shown above): private func transcribe() { guard let recognizer, recognizer.isAvailable else { print("--- SpeechRec.transcribe - SpeechRecognizer TRANSCRIBE ERROR: \(RecognizerError.recognizerIsUnavailable)") return } do { if let audioEngine { let request = SFSpeechAudioBufferRecognitionRequest() request.shouldReportPartialResults = true request.requiresOnDeviceRecognition = false // might fix speechRec error 1101 in console let audioSession = AVAudioSession.sharedInstance() try audioSession.setCategory(.playAndRecord, mode: .measurement, policy: .default, options: .duckOthers) try audioSession.setActive(true, options: .notifyOthersOnDeactivation) let inputNode = audioEngine.inputNode let recordingFormat = inputNode.outputFormat(forBus: 0) inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer: AVAudioPCMBuffer, _) in request.append(buffer) } try audioEngine.start() self.recognitionTask = recognizer.recognitionTask(with: request, delegate: self) } else { let (audioEngine, request) = try Self.prepareEngine() self.audioEngine = audioEngine self.request = request self.recognitionTask = recognizer.recognitionTask(with: request, delegate: self) } } catch { Logger.audio.error("--- SpeechRec.transcribe - SpeechRecognizer AudioSession/AudioEngine ERROR: \(error)") self.reset() } } This is the backtrace that the Organizer shows in Xcode: Last Exception Backtrace (0) #0 (null) in __exceptionPreprocess () #1 (null) in objc_exception_throw () #2 (null) in +[NSException raise:format:arguments:] () #3 (null) in AVAE_RaiseException(NSString*, ...) () #4 (null) in AVAudioIONodeImpl::SetOutputFormat(unsigned long, AVAudioFormat*) () #5 (null) in AUGraphNodeBaseV3::CreateRecordingTap(unsigned long, unsigned int, AVAudioFormat*, void (AVAudioPCMBuffer*, AVAudioTime*) block_pointer) () #6 (null) in -[AVAudioNode installTapOnBus:bufferSize:format:block:] () #7 0x100d34e10 in SpeechRecognizer.transcribe() at /Users/klaus/Developer/ScriptBuddy/ScriptBuddy/Assistants/SpeechRecognizer.swift:245 #8 0x100d34298 in SpeechRecognizer.startTranscribing(andCompareTo:) at /Users/klaus/Developer/ScriptBuddy/ScriptBuddy/Assistants/SpeechRecognizer.swift:167 #9 (null) in Script.speakNextScriptElement() () #10 0x100d43bfc in specialized SpeechSynthesizer.speechSynthesizer(_:didFinish:) at /Users/klaus/Developer/ScriptBuddy/ScriptBuddy/Assistants/SpeechSynthesizer.swift:942 #11 (null) in SpeechSynthesizer.speechSynthesizer(_:didFinish:) () #12 (null) in @objc SpeechSynthesizer.speechSynthesizer(_:didFinish:) () #13 (null) in -[AVSpeechSynthesizer(PublicSpeechImplementation) processSpeechJobFinished:successful:] () #14 (null) in -[AVSpeechSynthesizer(PublicSpeechImplementation) _handleSpeechDone:successful:] () #15 (null) in __67-[AVSpeechSynthesizer(PublicSpeechImplementation) _speakUtterance:]_block_invoke_6 () #16 (null) in __46-[TTSSpeechManager _speechJobFinished:action:]_block_invoke () #17 (null) in _dispatch_call_block_and_release () #18 (null) in _dispatch_client_callout () #19 (null) in _dispatch_main_queue_drain () #20 (null) in _dispatch_main_queue_callback_4CF () #21 (null) in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ () #22 (null) in __CFRunLoopRun () #23 (null) in CFRunLoopRunSpecific () #24 (null) in GSEventRunModal () #25 (null) in -[UIApplication _run] () #26 (null) in UIApplicationMain () #27 (null) in closure #1 in KitRendererCommon(_:) () #28 (null) in runApp<A>(_:) () #29 (null) in static App.main() () #30 (null) in static ScriptBuddyApp.$main() () #31 (null) in main () #32 (null) in start ()
Sep ’24
Reply to Error throws while using the speech recognition service in my app
The error Code=1101 often has to do with incorrect/incomplete setup off offline dictation on your device. If you set request.requiresOnDeviceRecognition = true the recognition process uses Apple’s dictation service. The dictation service only works offline if you have the keyboard installed for the same language + region you want the dictation / speech recognition for you have Enable Dictation toggled On and the Dictation Language for the lang + region you want has been downloaded by the system. If the above conditions are not met, you will see the 1101 error. Example: If you want offline dictation for „de-DE“ (german language for region Germany) you need to have such a keyboard installed. In the device's Setting / General / Keyboard / Keyboards … be sure to have the one keyboard installed for your lang + region speech recognition (in our example „German (Germany)“). Further down in General / Keyboard turn on Enable Dictation. If Dictation is enabled, you see a further entry below called Dictation Languages. Open it to make sure the dictation languages are downloaded (you see a note about the status there). Once the dictation language(s) are downloaded, speech recognition with request.requiresOnDeviceRecognition = true should work for that language/region.
Feb ’24
Reply to Failure of speech recognition when "supportsOnDeviceRecognition" is set to "True".
The error Code=1101 often has to do with incorrect/incomplete setup off offline dictation on your device. If you set request.requiresOnDeviceRecognition = true the recognition process uses Apple’s dictation service. The dictation service only works offline if you have the keyboard installed for the same language + region you want the dictation / speech recognition for you have Enable Dictation toggled On and the Dictation Language for the lang + region you want has been downloaded by the system. If the above conditions are not met, you will see the 1101 error. Example: If you want offline dictation for „de-DE“ (german language for region Germany) you need to have such a keyboard installed. In the device's Setting / General / Keyboard / Keyboards … be sure to have the one keyboard installed for your lang + region speech recognition (in our example „German (Germany)“). Further down in General / Keyboard turn on Enable Dictation. If Dictation is enabled, you see a further entry below called Dictation Languages. Open it to make sure the dictation languages are downloaded (you see a note about the status there). Once the dictation language(s) are downloaded, speech recognition with request.requiresOnDeviceRecognition = true should work for that language/region.
Feb ’24
Reply to AVAudioEngine: audio input does not work on iOS 17 simulator
You need to activate the AudioSession. I have added the following line to your code sample from github try! AVAudioSession.sharedInstance().setActive(true) after the setCategory line. Then it works for me on an iOS 17.2 simulator. I can confirm that your code works on iOS 16.4 Simulator without setActive. Not sure why, as my understanding is it has always been the intended way of doing stuff using setActive.
Jan ’24
Reply to AVSpeechSynthesizer iOS 15/16 lagging for seconds when switching to (different) German language voice
Today I have been testing something unrelated in my SpeechApp on the iOS 16.4 Simulator with Xcode 14.2 (and later 14.3) and to my surprise, the change of German languages from one utterance to the next worked as fast as it should be, no more 3+ secs delay! Cool, has Apple finally solved the bug?! I moved to a device. But no: on device with iOS 16.4.1 installed, the same issue as always, the delays between utterances with different German voices are back. Reinstalled the app on the device, re-downloaded the German voices used. But no luck. This is the console output of the app running on device. The delay happens after the first "[AXTTSCommon] Invalid rule:" appears in the console. Speech Synthesizer - Current utterance voice: Optional("Viktor (Enhanced)") | language: Optional("de-DE") 2023-04-09 13:04:06.172618+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule: <----- DELAY HAPPENS AFTER THIS LINE 2023-04-09 13:04:10.052499+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule: 2023-04-09 13:04:10.053138+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule: 2023-04-09 13:04:10.055567+0200 SpeechApp[914:31631] [AXTTSCommon] Invalid rule: 2023-04-09 13:04:10.113567+0200 SpeechApp[914:31164] [audio] --- SpeechSynthesizer Delegate - did START speaking utterance. The console output of the Simulator. It shows only one line with "[AXTTSCommon] Invalid rule:" and moves over it quickly, without any delay: Speech Synthesizer - Current utterance voice: Optional("Viktor (Enhanced)") | language: Optional("de-DE") 2023-04-09 13:01:59.764986+0200 SpeechApp[7145:111421] [AXTTSCommon] Invalid rule: 2023-04-09 13:01:59.778640+0200 SpeechApp[7145:108690] [audio] --- SpeechSynthesizer Delegate - did START speaking utterance. Can anybody confirm that German voices work correctly on Simulator while switching german voices between utterances, while still showing unacceptable delays between utterances on device?
Apr ’23