If I inspected the stamps for callbacks from the SFSpeechRecognizer
recognitionTask
callback (on macOS):
recognitionTask = speechRecognizer.recognitionTask( with: recognitionRequest )
{ result, error in
// if more than two seconds elapsed since the last update, we send a notification
NSLog( "speechRecognizer.recognitionTask callback" )
:
... I observe:
:
2019-11-08 14:51:00.35 ... speechRecognizer.recognitionTask callback
2019-11-08 14:51:00.45 ... speechRecognizer.recognitionTask callback
2019-11-08 14:51:32.31 ... speechRecognizer.recognitionTask callback
i.e. There is an additional unwanted callback approximately 30 seconds after my last utterance.
result
is nil
for this last callback.
The fact that it's close to 30 seconds suggests to me it is representing a max-timeout.
I'm not expecting a time out, because I have manually shutdown my session (at around the 5s mark, by clicking a button):
@objc
func stopRecording()
{
print( "stopRecording()" )
// Instructs the task to stop accepting new audio (e.g. stop recording) but complete processing on audio already buffered.
// This has no effect on URL-based recognition requests, which effectively buffer the entire file immediately.
recognitionTask?.finish()
// Indicate that the audio source is finished and no more audio will be appended
recognitionRequest?.endAudio()
//self.recognitionRequest = nil
audioEngine.stop()
audioEngine.inputNode.removeTap( onBus: 0 )
//recognitionTask?.cancel()
//self.recognitionTask = nil
self.timer?.invalidate()
print( "stopRecording() DONE" )
}
There's a lot of commented out code, as it seems to me there is some process I'm failing to shut down, but I can't figure it out.
Complete code is here.
Can anyone see what's going wrong?