ios speech recognition Error Domain=kAFAssistantErrorDomain Code=216 “(null)”

前端 未结 4 1998
死守一世寂寞
死守一世寂寞 2020-12-28 19:59

Basically I am learning ios speech recognition module following this tutorial: https://medium.com/ios-os-x-development/speech-recognition-with-swift-in-ios-10-50d5f4e59c48

4条回答
  •  不思量自难忘°
    2020-12-28 20:42

    This will prevent two errors: The above mentioned Code=216 and the 'SFSpeechAudioBufferRecognitionRequest cannot be re-used' error.

    1. Stop recognition with finish not with cancel

    2. Stop audio

    like so:

        // stop recognition
        recognitionTask?.finish()
        recognitionTask = nil
    
        // stop audio
        request.endAudio()
        audioEngine.stop()
        audioEngine.inputNode.removeTap(onBus: 0) // Remove tap on bus when stopping recording.
    

    P.S. audioEngine.inputNode seems to be no longer an optional value, therefore I used no if let construct.

提交回复
热议问题