Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

275
Views
Microsoft azure "text to speech" javascript, onend event

Good day.

I'm making a website, integrating the microsoft text-to-speech API. And I need to activate a function when the audio finishes playing it.

I've been doing a lot of research but I didn't find any method that really works.

Some "onend" event that works.

Do you know how I could achieve this? Thank you

    startSpeakTextAsyncButton.addEventListener("click", function () {
          startSpeakTextAsyncButton.disabled = true;
          resultDiv.innerHTML = "";
          
          synthesizer = new SpeechSDK.SpeechSynthesizer(speechConfig);
  
          synthesizer.speakTextAsync(
            phraseDiv.value,
            function (result) { 
              startSpeakTextAsyncButton.disabled = false;
              resultDiv.innerHTML = "synthesis in process";
              if (result.reason === SpeechSDK.ResultReason.SynthesizingAudioCompleted) {
                resultDiv.innerHTML = "synthesis finished";
              } else if (result.reason === SpeechSDK.ResultReason.Canceled) {
                resultDiv.innerHTML = "synthesis failed. Error detail: " + result.errorDetails + "\n";
              }
              
              synthesizer.close();
              synthesizer = undefined;
            },
            function (err) { 
              startSpeakTextAsyncButton.disabled = false;
              resultDiv.innerHTML = "Error: ";
              resultDiv.innerHTML = err;
              resultDiv.innerHTML = "\n";
              window.console.log(err);
  
              synthesizer.close();
              synthesizer = undefined;
          });

        });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!