Ad

How To Detect End Of Speech In ResponsiveVoice JS

- 1 answer

I'm working with the ResponsiveVoice text to speech library.

Everything is working perfectly fine except there seems to be no way of detecting the end of speech in the API.

On the responsiveVoice object I'm able to see the OnFinishedPlaying callback but it doesn't work. Neither does the onendcallback mentioned here.

Right now I'm using the setInterval to poll on isPlaying method to detect the end of speech. However it would be great if there was a method to do so properly.

Here's the code on Github that I'm working with.

And here's a minimal JSFiddle test code.

Ad

Answer

The mentioned onend callback is working if you put the options object as the 3rd parameter:

responsiveVoice.speak('Responsive Voice is ready', 'UK English Male', {onend: yourCallbackGoesHere});

See JSFiddle

Ad
source: stackoverflow.com
Ad