我想同时使用两个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()
时,不是同时阅读文本,而是一次又一次地阅读。
答案 0 :(得分:1)