我想同时使用两个 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()
andbar()
时,文本不是同时阅读,而是一个接一个。