SFSpeechRecognizer on MacOS - crash

I'm debuggin a macOS application that uses SFSpeechRecognizer to translate a video or audio file into a text file.

I think that I'm doing something wrong when I call SFSpeechRecognizer.

Here is the code:

     guard let myRecognizer = SFSpeechRecognizer() else {
      // A recognizer is not supported for the current locale
      print("Recognizer not supported for current locale")
      self.titleText = "Recognizer not supported for current locale"
      return
    }
     
    if !myRecognizer.isAvailable {
      // The recognizer is not available right now
      print("Recognizer is not available right now")
      self.titleText = "Recognizer is not available right now"
      return
    }
         
    let request = SFSpeechURLRecognitionRequest(url: url)
    myRecognizer.recognitionTask(with: request) { (result, error) in

And this is the relevant stack trace.

Application Specific Backtrace 0:
0   CoreFoundation                      0x00000001b5e9d148 __exceptionPreprocess + 240
1   libobjc.A.dylib                     0x00000001b5be7e04 objc_exception_throw + 60
2   AVFCore                             0x00000001c851701c -[AVAssetReaderAudioMixOutput initWithAudioTracks:audioSettings:] + 984
3   AVFCore                             0x00000001c8516c28 +[AVAssetReaderAudioMixOutput assetReaderAudioMixOutputWithAudioTracks:audioSettings:] + 52
4   Speech                              0x00000001e46f1348 __151-[SFSpeechURLRecognitionRequest _handlePreRecordedAudioWithAsset:audioTracks:narrowband:addSpeechDataBlock:stopSpeechBlock:cancelSpeechWithErrorBlock:]_block_invoke.227 + 380
5   Speech                              0x00000001e46f1130 __151-[SFSpeechURLRecognitionRequest _handlePreRecordedAudioWithAsset:audioTracks:narrowband:addSpeechDataBlock:stopSpeechBlock:cancelSpeechWithErrorBlock:]_block_invoke + 212
6   libdispatch.dylib                   0x00000001b5b8a5f0 _dispatch_call_block_and_release + 32
7   libdispatch.dylib                   0x00000001b5b8c1b4 _dispatch_client_callout + 20
8   libdispatch.dylib                   0x00000001b5b8f2c8 _dispatch_queue_override_invoke + 784
9   libdispatch.dylib                   0x00000001b5b9d8e8 _dispatch_root_queue_drain + 396
10  libdispatch.dylib                   0x00000001b5b9e104 _dispatch_worker_thread2 + 164
11  libsystem_pthread.dylib             0x00000001b5d4c324 _pthread_wqthread + 228
12  libsystem_pthread.dylib             0x00000001b5d4b080 start_wqthread + 8

Full ips file attached. Thanks for taking a look :)

Found this stack overflow post: https://stackoverflow.com/questions/63592450/sfspeechrecognizer-crashes-if-no-microphone-input-attached-in-mac-osx

Not sure if the same problem or not. Doesn't seem like I should have to check outside of error handling inside the speech recognition method

Hey there, thanks for posting about the crash you're hitting here. Could you also please upload your code sample, crash log file you have here, as well as mention which line of code in your execution which is crashing into a bug report: https://developer.apple.com/bug-reporting/

SFSpeechRecognizer on MacOS - crash
 
 
Q