Reputation: 1895
I'm facing the issue with Azure speakTextAsync
callback issue it's azure
SpeechSDK
support?
Here is the sample link -> You can check
Code
try
{
var player = new SpeechSDK.SpeakerAudioDestination();
var audioConfig = SpeechSDK.AudioConfig.fromSpeakerOutput(player);
var speechConfig = SpeechSDK.SpeechConfig.fromSubscription("KEY", "REGION");
speechConfig.speechSynthesisLanguage = getCurrentLanguageCode();
synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig, audioConfig);
synthesizer.speakTextAsync(
inputText,
function (result) {
console.log(result)
if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) {
//some callback
}
synthesizer.close();
},
function (err) {
synthesizer.close();
})
synthesizer.synthesisCompleted = function (s, e) {
console.log(s)
console.log(e)
//some callback
};
} catch (e) {
console.log(e.message);
}
In this, I've tried two ways
SpeechSDK.ResultReason.SynthesizingAudioCompleted
synthesizer.synthesisCompleted
But both are called when the speakTextAsync
method call.
Upvotes: 2
Views: 982
Reputation: 1895
I've found the solution
Just need to add the code
Player code
player.onAudioEnd = function () {
console.log('speakTextAsync finished');
}
Full speak code
synthesizer.speakTextAsync(
inputText,
function (result) {
synthesizer.close();
player.onAudioEnd = function () {
console.log('speakTextAsync finished');
}
},
function (err) {
synthesizer.close();
})
Upvotes: 2