Voice.cancelSpeech()

Overview

Stops the current phrase being spoken and cancels any queued speech phrases.

Added in Velocity version 2.1.25

Added in Speakeasy version 1.0.21

Use Cases

You want Speakeasy to stop talking.

You want an utterance to be heard immediately instead of being queued. For example, you can use Voice.cancelSpeech() immediately before Voice.speak().

Format

Voice.cancelSpeech();

Example

Copy
/* Speak every printable ASCII key pressed by the user.
 * Cancel all queued speech when the ESC key is pressed.
 */

WLEvent.on("Key", function(e) {
    var code = Number(e.keyCode);
    if(code > 32 && code < 127) {
        var ch = String.fromCharCode(code);
        Voice.speak("You pressed {readmode:character}"+ch+"{reset}");
    }
    
    if(code === 27 /* ESC */) {
        Voice.cancelSpeech();
    }
});