【问题标题】:Siri implementation app getting crash reason Terminating app due to uncaught exceptionSiri 实现应用程序出现崩溃原因由于未捕获的异常而终止应用程序
【发布时间】:2017-05-16 07:52:35
【问题描述】:

'com.apple.coreaudio.avfaudio', reason: '要求条件为假:_recordingTap == nil

代码崩溃

1.  
guard let inputNode = audioEngine.inputNode else {
        fatalError("Audio engine has no input node")
    }  
2.  
inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { (buffer, when) in
        self.recognitionRequest?.append(buffer)
}

当尝试重新初始化 siri 时它崩溃了

我们在听写后也有文字听写,我想从语音中捕获文本。第一次没问题,但第二次在第 2 行崩溃

下面给出的语音听写功能

func getSpeech(asSpeach:String)
{
    print("===================")

    let audioSession  = AVAudioSession.sharedInstance()
    do {
        try audioSession.overrideOutputAudioPort(.speaker)
    } catch {
        print(error.localizedDescription)
    }


    /// <#Description#>
    let synthesizer = AVSpeechSynthesizer()
    let utterance = AVSpeechUtterance(string: asSpeach)
    utterance.rate = AVSpeechUtteranceDefaultSpeechRate
    utterance.volume = 1.0
    utterance.pitchMultiplier = 1.0
    synthesizer.delegate=self
    synthesizer.speak(utterance)

    //        synthesizer.rSpeaking(at: .word)


}

【问题讨论】:

    标签: ios swift siri sirikit


    【解决方案1】:

    错误是告诉您,您已经在该总线上安装了一个水龙头,并且您不能再安装一个。

    当您最初调用listen() 时,您将tap 安装在总线上。 然后你调用 stopListening() 并停止你的识别,但你对点击不做任何事情。 然后,当您再次调用 listen() 时,您会尝试再次安装水龙头 - 这会产生错误。

    您可以在 stopListening() 时向 removeTapOnBus 添加一些内容 - 这应该意味着您可以在再次开始收听时重新添加它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-05
      • 2013-04-27
      • 2021-09-17
      • 2012-07-12
      • 2021-02-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多