【发布时间】:2013-12-02 13:58:05
【问题描述】:
我在我的应用程序中使用 AVSpeechSynthesizer 进行文本转语音。是否可以在中间停止播放,例如如果用户点击停止按钮?
【问题讨论】:
标签: ios iphone ios7 text-to-speech avspeechsynthesizer
我在我的应用程序中使用 AVSpeechSynthesizer 进行文本转语音。是否可以在中间停止播放,例如如果用户点击停止按钮?
【问题讨论】:
标签: ios iphone ios7 text-to-speech avspeechsynthesizer
查看Documentation for AVSpeechSynthesizer,你需要先拨打-[AVSpeechSynthesizer pauseSpeakingAtBoundary:]停止讲话,然后再拨打-[AVSpeechSynthesizer continueSpeaking]继续讲话。
您可以选择立即暂停讲话 (AVSpeechBoundaryImmediate),或者在当前单词的末尾 (AVSpeechBoundaryWord)。
【讨论】:
迅速:
synthesizer.stopSpeaking(at: .immediate)
或
synthesizer.stopSpeaking(at: .word)
【讨论】: