microsoft / cognitive-services-speech-sdk-js

Microsoft Azure Cognitive Services Speech SDK for JavaScript
Other
267 stars 101 forks source link

[Bug]: SpeakerAudioDestination > onAudioEnd does not work #826

Open sinajia opened 6 months ago

sinajia commented 6 months ago

What happened?

function audioEnd () { console.log('audioEnd'); }

const player = new speechsdk.SpeakerAudioDestination(); player.onAudioEnd = audioEnd; const audioConfig = speechsdk.AudioConfig.fromSpeakerOutput(player); const synthesizer = new speechsdk.SpeechSynthesizer(speechConfig, audioConfig);

After the sound is played, the end event function is not executed.

Version

1.36.0 (Latest)

What browser/platform are you seeing the problem on?

Chrome

Relevant log output

No response

pengkobe commented 1 month ago

You must add synthesizer.close(() => {}) within the synthesisCompleted event, and then it will trigger as expected.