I am using Nuance's Speechkit 2 with swift, iOS 9.3. Ineed to detect when the TTS finishes, according to this documentation:
https://developer.nuance.com/public/Help/DragonMobileSDKReference_iOS/Speech-synthesis.html
...These are the 3 delegate methods available for TTS:
// SKTransactionDelegate
func transaction(transaction: SKTransaction!, didReceiveAudio audio: SKAudio!) { ... }
func transaction(transaction: SKTransaction!, didFinishWithSuggestion suggestion: String!) { ... }
func transaction(transaction: SKTransaction!, didFailWithError error: NSError!, suggestion: String!) { ... }
Also, here is a sample Swift project (https://developer.nuance.com/public/index.php?task=prodDev), where the TTS example uses an extra, SKAudioPlayerDelegate, and in the code I saw this delegate method, however it NEVER triggers:
func audioPlayer(player: SKAudioPlayer!, willBeginPlaying audio: SKAudio!) {
log("willBeginPlaying")
// The TTS Audio will begin playing.
}
I am calling TTS with:
var skTransaction = skSession!.speakString("a long sentence here",withLanguage: "eng-USA",delegate: self)
However, "didFinishWithSuggestion" always triggers long before the TTS voice has finished speaking, which seems like a bug for me. Nuance technical support won't reply, can anybody help me? Thanks.
I found the solution. It turns out, that a 2nd delegate is responsible for detecting the beginning, and end, of TTS playback:
These are the delegate methods: