原因:“所需条件为假:_recordingTap ==为零”
代码崩溃
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时,它会崩溃
我们有文字听写,也在听写之后,我想从语音中捕捉文本。第一次没问题,第二次在二号线坠毁。
语音听写功能
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)
}发布于 2017-05-16 08:22:20
错误是告诉您,您已经安装了该总线上的一个抽头,并且您不能再安装一个。
当您调用listen()时,首先在总线上安装水龙头。然后调用stopListening(),停止识别,但不对抽头做任何事情。然后,当您再次调用that ()时,您将再次尝试安装tap --这会产生错误。
您可以在removeTapOnBus ()中添加一些内容--这意味着您可以在再次开始侦听时再次添加它。
https://stackoverflow.com/questions/43995478
复制相似问题