ios - 同时使用两个 AVSpeechSynthesizer 实例

标签 ios swift avspeechsynthesizer avspeechutterance

我想同时使用两个 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/

相关文章:

ios - Swift 图表 X 轴不显示?

iOS:AVSpeechSynthesizer 在使用 SFSpeechRecognizer 录制后不起作用

ios - Azure 推送通知 + .NET 后端 API - 未发送通知

ios - 我怎么知道用户单击了静态TableView中的节标题

ios - UIButton 在 CABasicAnimation 期间不显示选定状态

ios - 指定任务之间的时间 - iOS

ios - 如果 self 是 SKSpriteNode 导致崩溃,则不提供与崩溃相关的详细信息

ios - Swift 无法从上到下呈现 View Controller

Swift avspeechsynthesizer 不同的语言

ios - 初始化程序不会覆盖其父类(super class) Swift 2.0 中的指定初始化程序