capacitor-community/text-to-speech

feat: speak method should use the internal queue of utterances

iLoveBug opened this issue · 4 comments

Is your feature request related to a problem? Please describe.
Some times we could get a text to speak while the previous one is not finished. Currently, each time we call speak() method will cause the queue is flushed and the previous one is stopped immediately.

Describe the solution you'd like
I propose to use the internal queue of utterances, like it is described in the apple document:

The speech synthesizer maintains a queue of utterances that it speaks. If the synthesizer isn’t currently speaking, calling speak(_:) begins speaking that utterance immediately (or begin waiting through its preUtteranceDelay if set). If the synthesizer is speaking, the synthesizer adds utterances to a queue and speaks them in the order received.

Describe alternatives you've considered
Or we can resolve the speak method only after the text is really spoken but not just after the call in invoked immediately.

Good point. On Anroid and Web, speak should only resolve after the text is spoken. On iOS this does not currently work (#52).
As far as I know all platforms support the queue.

#52 is now fixed (see #59).

I have a different implementation, please have look at: https://github.com/iLoveBug/text-to-speech.git branch non-stop-tts

yes, I've looked at it. The fix is not yet included there.