Detect when TTS has finished to speak

810 views
Skip to first unread message

Guillaume Caplain

unread,
May 16, 2012, 11:55:50 AM5/16/12
to phonegap
Hi,

I try to insert TTS speech between audio files (with a media object),
but media sound start before the end of the TTS speech.

An example of my code :

function startTraining() {
window.plugins.tts.speak("my text", onSpeakSuccess, onSpeakError);
}

function onSpeakSuccess() {
myMedia.play();
}

I thank than onSpeakSuccess should be called at the end of the speech
but it doesn't seems to be that.

If someone can help me.
Regards,
Guillaume Caplain

Guillaume Caplain

unread,
May 17, 2012, 2:00:23 PM5/17/12
to phonegap
HI,

After some research, I found on Android developper website (http://
android-developers.blogspot.fr/2009/09/introduction-to-text-to-speech-
in.html) that the function "speak" is asynchronous and after looking
the code of the TTS plugin, I saw that no function to do a completion
callback exists.

To solve my problem I have added a function which defines a javascript
function to execute when the speak function is completed.

I don't know if my code is beautiful but it works great, if you are
interested, how can I give you the code in order to maybe include it
in the github source?

Regards,
Guillaume Caplain


On 16 mai, 17:55, Guillaume Caplain <guillaume.capl...@gmail.com>
wrote:
> Hi,
>
> I try to insertTTSspeech between audio files (with a media object),

Simon MacDonald

unread,
May 17, 2012, 2:05:35 PM5/17/12
to phon...@googlegroups.com
Yes, I am interested in it. Especially since I originally wrote the
plugin for Android. Can you do a pull request in Github so I can
review?

Simon Mac Donald
http://hi.im/simonmacdonald
> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com

Guillaume Caplain

unread,
May 18, 2012, 1:22:05 PM5/18/12
to phonegap
Hi,

I put the code in this issue (I am newbie in github I don't find how
to open a pull request).
https://github.com/purplecabbage/phonegap-plugins/issues/81

Be careful I have done some modifications because I don't work with
cordova 1.5.

Regards,
Guillaume Caplain

On 17 mai, 20:05, Simon MacDonald <simon.macdon...@gmail.com> wrote:
> Yes, I am interested in it. Especially since I originally wrote the
> plugin for Android. Can you do a pull request in Github so I can
> review?
>
> Simon Mac Donaldhttp://hi.im/simonmacdonald
>
> On Thu, May 17, 2012 at 2:00 PM, Guillaume Caplain
>
>
>
>
>
>
>
> <guillaume.capl...@gmail.com> wrote:
> > HI,
>
> > After some research, I found on Android developper website (http://
> > android-developers.blogspot.fr/2009/09/introduction-to-text-to-speech-
> > in.html) that the function "speak" is asynchronous and after looking
> > the code of theTTSplugin, I saw that no function to do a completion

Simon MacDonald

unread,
May 21, 2012, 2:42:18 PM5/21/12
to phon...@googlegroups.com
Hey Guillaume,

I thought you idea was a really good one but I approached it a bit
differently and pushed a different solution to the plugins repo.

https://github.com/phonegap/phonegap-plugins/tree/master/Android/TTS

Now when you call:

window.plugins.tts.speak("The TTS service is ready", win, fail);

The "win" callback is not called until the utterance is completely
spoken and that is pretty much how it should be.

Simon Mac Donald
http://hi.im/simonmacdonald


Reply all
Reply to author
Forward
0 new messages