How to implement this with streaming? [Question]
Hey! I Loved the framework.
We are working on an app that gets "chunks" of text (like a bot) from an API. We want to sync the API calls with the Speech. So we get something like:
"Hey" "Hey There" "Hey There Cute Puppy"
I assume we need an internal manager to feed the OSSVoice() object with the correct String. My question is, how can I properly achieve this from the framework perspective? Should I stop and re-speakText every time?
Hi @roimulia2, thanks for your kind works.
I assume you mean that you are receiving a stream of strings so you want to speak each string as it is received by your app? If so, then yes, you would need to ask the app to speak after each string is received in the stream so the stream would be:
"Hey there cute puppy"
As each word comes through you would call speechKit.speakText(text: $0) so it would be:
speechKit.speakText(text: "Hey")
speechKit.speakText(text: "There")
speechKit.speakText(text: "Cute")
speechKit.speakText(text: "Puppy")
Alternatively you could wait for the entire string to be received and call speechKit.speakText(text: "Hey there cute puppy") just the one time.
If I have misunderstood your question let me know.
Hey @AppDevGuy! Thank you for your response. This is an example input we are getting (streamed):
In
the
morning
light
the
world
aw
akes
The
birds
sing
In
the
still
ness
of
the
night,
Each line is the chunk we get. If I'll do speechKit.speakText(text: $0) It'll just speak the last word without the rest. I wonder if I should build my own service that will "queue" all the input from the stream and will check when the OSSpeech is finished, or do you have a better idea on how to achieve this?
Thank you!
I just saw that private var speechSynthesizer: AVSpeechSynthesizer!, I think it'll be useful to make it public so I can listen to the didFinished delegate (to handle the queue).