dlutton / flutter_tts

Flutter Text to Speech package
MIT License
617 stars 258 forks source link

Added progress events to flutter_tts_web using onboundary #526

Closed Robert01101101 closed 1 week ago

Robert01101101 commented 2 months ago

Added progress events for Web by adding a listener to SpeechSynthesisUtterance's onboundary event. The fix / added feature is in order to add the missing support for progress events on the Web, I had reported an issue on that earlier today: Fixes #525

This is my first time contributing to an open-source project, I hope I adhered to the best practices 😅

Some notes on the changes:

Robert01101101 commented 2 months ago

After running into some issues with this fix in my build, I want to add some additional notes. While my local debug build worked without issues, once I built for web, there were some limitations with the reliability of when onboundary events are fired.

From what I can tell:

I'd be happy to do more investigation or work on this proposed change!

dlutton commented 1 week ago

@Robert01101101 looks like there are some conflicts, please resolve when you have a moment so I can merge this in. Also any updates on your investigation?

Robert01101101 commented 1 week ago

@dlutton I've resolved the merge conflict.

Regarding the investigation, I believe onboundary events are not supported at the moment for non-default voices.

Status: Won't Fix (Obsolete) The boundary event is not supported for all speech engines. Native speech synthesis on Mac OS X, Windows, and Chrome OS all support boundary events at the word level. Network-based speech synthesis, and Android speech synthesis don't currently support these. There's no immediate plans to fix those as the upstream APIs literally don't expose them at all. There's a feature request filed with Google's speech time to provide word timing information for the speech synthesis API that Chrome uses, but that's not available at this time.

For my use case, I updated my app to default to the native voice in the web build and disabled the option to switch voice. With that, it's working consistently.

My suggestion would be to include a note in the Readme. If you'd like I can take care of that, but I'm not quite sure how to add it to this PR. Can I commit the changes to my branch, push it, and that would update the changes included in this PR? I resolved the merge conflict using GitHub's conflict resolve UI and locally tested code with the merge conflict fix I copy pasted.

dlutton commented 1 week ago

@Robert01101101 yes that would be great if you could update the README. You should be able to simply push to it.

Robert01101101 commented 1 week ago

@dlutton I ended up adding 3 more small commits:

Let me know if I can do anything else or if there are any issues with this PR. And thanks for creating this package, I find it very useful!