leaonline / easy-speech

🔊 Cross browser Speech Synthesis also known as Text to speech or TTS; no dependencies; uses Web Speech API
https://leaonline.github.io/easy-speech/
170 stars 20 forks source link

EasySpeech.speak stop currently playing speech #269

Open ivoryguard opened 2 months ago

ivoryguard commented 2 months ago

Hello.

The speak method of the W3C SpeechSynthesis API is responsible for queuing a SpeechSynthesisUtterance for text-to-speech (TTS). Therefore, window.speechSynthesis.speak(utterance) allows new text to be played without interrupting the currently playing speech.

However, when the EasySpeech.speak method is called, the current speech stops and the new text is played.

It seems that EasySpeech.speak should operate in a way similar to window.speechSynthesis.speak, adding the new SpeechSynthesisUtterance to the queue without interrupting the currently playing speech.

Or, is there a way for EasySpeech.speak to not interrupt the currently playing speech?

jankapunkt commented 2 months ago

Hi @ivoryguard and thank you for pointing this out. Currently this is hard-coded into EasySpeech. However, it should be easy (haha) to add another flag noStop to the speech method that, if truthy, will circumvent calling the stop method. What do you think? Mind to create a PR for this?

ivoryguard commented 2 months ago

I did it.

jankapunkt commented 2 months ago

Please try easy-speech@2.4.0-rc.0 and let me know if things work as expected