Closed liviu-padurariu closed 3 years ago
Thanks for the PR! There is one change I'd like you to make though, could you please remove if(ducking) {...} code.
It is used to release audio focus in the similar calls in onDone(), onError() and onStop() because these methods are called at the end of an utterance, while onRangeStart() is called while the utterance is being spoken, and can be called multiple times.
Sure thing, let me know if there is something else that I should change.
Okay, if you offering to make more changes :), let's do this:
onRangeStart() receives few more arguments: int start, int end, int frame which presumably point at some location in the utterance, and I guess it might be useful to send this info as well.
However, the sendEvent() method takes only one argument which is utteranceId, so to make things work we need to refactor it a little. Can you do the following:
Create additional sendEvent(String eventName, WritableMap params) method that would take existing params and ..emit(...) it.
Update existing sendEvent(String eventName, String utteranceId) method to use newly created sendEvent(String eventName, WritableMap params)
Update onRangeStart() to look something like that: ... WritableMap params = Arguments.createMap(); params.putString("utteranceId", utteranceId); params.putInt("start", start); params.putInt("end", end); params.putInt("frame", frame); sendEvent("tts-progress", params); ...
Looks good! I'm merging it. Did you test these? If it works for you, I'm going to publish the new version later today.
Yes, everything works the same. Now you can get all from the onRangeStart args in the tts-progress event.
Thanks a lot for your contribution! The new release has been published.
It doesn't work for me on android. Can you tell me how to run it?
I've noticed that android is not triggering the tts-progress event. One could use the
onRangeStart
method to trigger the event.I've tested succesfully on my project where I have a progress bar that gets updated for each word.