Vhost API - Speech Functions: Text to Speech functions (Scene embedded in HTML)

loadText(txt,voice,lang,engine)


You may pre-load the Text to Speech audio in order to achieve a faster effect when calling the sayText() command:
  1. Call the loadAudio() command: loadText('The text is ready',2,1,3)

  2. Use the Javascript event function vh_ttsLoaded(args) in the HEAD section to check if the audio track is loaded: "function vh_ttsLoaded(args){"
    In this example you will see a JavaScript alert displayed when the text is ready.


  3. When the text is loaded, play it using the sayText() command:
    "sayText(args, 2,1,3);"


    Note: In this example we check to see if the text was loaded and only then play it. The Text to Speech audio will play even if the pre-load was not done yet.

See the source of this page for the API code