【问题标题】:How to detect end of speech with Nuance Vocalizer, Speechkit 2, for iOS如何使用适用于 iOS 的 Nuance Vocalizer、Speechkit 2 检测语音结束
【发布时间】:2016-06-29 15:39:34
【问题描述】:

我正在使用 Nuance 的 Speechkit 2 和 swift,iOS 9.3。 根据此文档,需要检测 TTS 何时完成:

https://developer.nuance.com/public/Help/DragonMobileSDKReference_iOS/Speech-synthesis.html

...这些是可用于 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 语音说完之前很久就触发,这对我来说似乎是一个错误。 Nuance 技术支持不会回复,有人可以帮助我吗?谢谢。

【问题讨论】:

    标签: ios swift swift2 text-to-speech speechkit


    【解决方案1】:

    我找到了解决方案。事实证明,第二个代表负责检测 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")
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-04
      • 1970-01-01
      • 1970-01-01
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      • 2021-08-17
      • 1970-01-01
      相关资源
      最近更新 更多