Skip to content

JavaScript API

Aymeric edited this page Oct 17, 2013 · 24 revisions

Here you'll find the specific JavaScript functions you can use in your plugin and that are related to SARAH.

SARAH.speak(sentence, [callback])

## Parameters

  • {String} Sentence : this is the sentence that SARAH will say
  • {Function} [callback] : (optional) this is a callback function that will be called when the sentence has been said

Comments

The call is asynchronous. So if you do:

SARAH.speak("Hello");
SARAH.speak("world");
SARAH.speak("I'm Sarah");

Then it will send 3 HTTP requests and only 1 will be said by SARAH. It's because the TTS requests are ignored when SARAH is currently speaking.

From SARAH V3.0 it's possible to change this behavior with cascading calls:

SARAH.speak("Hello", function(){
  SARAH.speak("world", function(){
    SARAH.speak("I'm Sarah", function(){
        // ...
    })
  })
})

It's still possible to use SARAH.shutUp() at any time to stop SARAH for speaking.

Clone this wiki locally