我正在使用Nuance的Speechkit 2与斯威夫特,iOS 9.3。根据以下文档,Ineed用于检测TTS何时完成:
...These是TTS可用的3种委托方法:
// SKTransactionDelegate
func transaction(transaction: SKTransaction!, didReceiveAudio audio: SKAudio!) { ... }
func transaction(transaction: SKTransaction!, didFinishWithSuggestion suggestion: String!) { ... }
func transaction(transaction: SKTransaction!, didFailWithError error: NSError!, suggestion: String!) { ... }另外,下面是一个示例Swift项目(https://developer.nuance.com/public/index.php?task=prodDev),其中TTS示例使用了一个额外的SKAudioPlayerDelegate,在代码中我看到了这个委托方法,但是它从不触发:
func audioPlayer(player: SKAudioPlayer!, willBeginPlaying audio: SKAudio!) {
log("willBeginPlaying")
// The TTS Audio will begin playing.
}我打电话给TTS的目的是:
var skTransaction = skSession!.speakString("a long sentence here",withLanguage: "eng-USA",delegate: self)然而,"didFinishWithSuggestion“总是在TTS语音结束之前就触发了,这对我来说似乎是个bug。细微的技术支持不会回答,有人能帮我吗?谢谢。
发布于 2016-07-05 13:06:32
我找到了解决办法。事实证明,第二个委托负责检测TTS回放的开始和结束:
class ViewController: UIViewController, SKAudioPlayerDelegate{
//All your view controller code here...
func viewDidLoad(){
//more init. code
skSession!.audioPlayer.delegate=self
}
}这些是委托方法:
func audioPlayer(player: SKAudioPlayer!, willBeginPlaying audio: SKAudio!){
print("Starting TTS")
}
func audioPlayer(player: SKAudioPlayer!, didFinishPlaying audio: SKAudio!) {
print("TTS FINISHED")
}https://stackoverflow.com/questions/38104248
复制相似问题