Closed webmagnets closed 7 years ago
Hi. https://github.com/tom-s/speak-tts/blob/master/src/speak-tts.js -> line 223 we loop on the sentences and play them. Line 244 we assign the onEnd event, you want to assign it for the last sentance only (this is a bug, my bad). I don't have much time to do it at the moment but feel free to submit a PR.
I had a look at the code and try a few things, but I am too inexperienced to fix it. I don't understand the code.
something like
sentences.forEach((sentence, index) => { ... utterance.onend = (e) => { if(onEnd && index === sentences.length - 1) onEnd() }
I did the change, you can see the PR here : https://github.com/tom-s/speak-tts/pull/2
I publish on npm, it's version 1.0.1 now.
Please close the issue if it works for you.
I am having this speak a paragraph. The
onEnd
callback fires when the first sentence is finished. How can I makeonEnd
fire when the full paragraph string is spoken?Thanks for all your work on this project!