Using Callbacks

This example shows how to use callbacks with responsiveVoice.speak().

You can add callbacks to be triggered in some speech related events. Supported callbacks are:

onstart: Speech started playing.
onend: Speech ended playing.
onerror: There was some error.
onpause*: Speech was paused.
onresume*: Speech started playing after being paused.

*Only available in Chrome.

This is example code to add just before the closing body tag.

<script>
function voiceStartCallback() {
    console.log("Voice started");
}

function voiceEndCallback() {
    console.log("Voice ended");
}

var parameters = {
    onstart: voiceStartCallback,
    onend: voiceEndCallback
}

responsiveVoice.speak("Hello, this is a test using callbacks","UK English Female", parameters);
</script>

Keywords: callback, events

Are You Interested In
VOICE ENABLING YOUR SITE
WITH JUST ONE LINE OF CODE?