我正在我的应用程序中实现语音识别.当我第一次使用语音识别逻辑呈现视图控制器时,一切正常.但是,当我再次尝试呈现视图控制器时,我得到以下崩溃:
ERROR: [0x190bf000] >avae> AVAudioNode.mm:568: CreateRecordingTap: required condition is false: IsFormatSampleRateAndChannelCountValid(format)
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(format)'
Run Code Online (Sandbox Code Playgroud)
以下是用于启动和停止录制的代码:
@available(iOS 10.0, *)
extension DictationViewController {
fileprivate func startRecording() throws {
guard let recognizer = speechRecognizer else {
debugLog(className, message: "Not supported for the device's locale")
return
}
guard recognizer.isAvailable else {
debugLog(className, message: "Recognizer is not available right now")
return
}
mostRecentlyProcessedSegmentDuration = 0
guard let node = audioEngine.inputNode else {
debugLog(className, message: …Run Code Online (Sandbox Code Playgroud) speech-recognition ios avaudioengine swift3 sfspeechrecognizer