【发布时间】: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)
}
【问题讨论】: