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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<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