microsoft / cognitive-services-speech-sdk-js

Microsoft Azure Cognitive Services Speech SDK for JavaScript
Other
261 stars 95 forks source link

[Bug]: synthesis is getting completed before the audio completion #847

Open Rohini-Microsoft opened 1 month ago

Rohini-Microsoft commented 1 month ago

What happened?

Description The speech synthesis process is incorrectly marked as completed before the audio playback is actually finished.

Steps to Reproduce Detailed steps to reproduce the issue:

  1. Set up the text-to-speech synthesis using 'microsoft-cognitiveservices-speech-sdk'
  2. Initiate a text-to-speech synthesis with a long text input.
  3. Observe the status of the synthesis completion versus the actual audio playback.

Expected Behavior The synthesis should be marked as completed only after the entire audio playback is finished.

Actual Behavior The synthesis is marked as completed before the audio playback is finished, resulting in an early indication of completion.

Code Snippet

const handleSpeak = async () => { try { const text = getAnswerText(); setIsSpeaking(true); const synth = await initializeSynthesizer(); const AudioContext = window.AudioContext || window.webkitAudioContext; const context = new AudioContext(); setAudioContext(context); synth.speakTextAsync( text, result => { if (result.reason === sdk.ResultReason.SynthesizingAudioCompleted) { console.log('Synthesis completed'); setIsSpeaking(false); setIsPaused(false); context.close(); } }, error => { console.error('Synthesis error:', error); setIsSpeaking(false); setIsPaused(false); context.close(); } ); } catch (error) { console.error('Error:', error); setIsSpeaking(false); setIsPaused(false); } };

Version

1.36.0 (Latest)

What browser/platform are you seeing the problem on?

No response

Relevant log output

No response

Rohini-Microsoft commented 1 month ago

The issue is that when I click on the speaker button, the synthesis ends before the audio does, so it's difficult to capture the event until it is finished.

image

Roopan-Microsoft commented 1 month ago

Hi @yulin-li / @glharper - Any update on the above issue?

Roopan-Microsoft commented 1 month ago

@yulin-li / @glharper - Can you please provide some updates here

nickcapitoubt commented 1 week ago

We are experiencing this issue as well. We need some reliable way to know when the audio is done playing.