我想同时使用两个 AVSpeechSynthesizer 实例。
let firstSynthesizer = AVSpeechSynthesizer()
let secondSynthesizer = AVSpeechSynthesizer()
func foo() {
let utterance = AVSpeechUtterance(string: "Foo Foo Foo Foo Foo")
utterance.rate = 0.4
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
firstSynthesizer.speak(utterance)
}
func bar() {
let utterance = AVSpeechUtterance(string: "Bar Bar Bar Bar Bar")
utterance.rate = 0.4
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
secondSynthesizer.speak(utterance)
}
当我调用 foo()
和 bar()
时,文本不是同时读取而是一个接一个读取。
最佳答案
I would like to use two instances of AVSpeechSynthesizer simultaneously.
这在 iOS 12 中肯定是不可能的,一次只处理一个语音合成。
然而,an audio session可以和语音合成一起播放。
关于ios - 同时使用两个 AVSpeechSynthesizer 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55622016/