Kiosk Project logo

KioskBrowser/XpcomFlite

KioskWiki | KioskBrowser | RecentChanges | Preferences

Flite XPCOM component

The [Flite] xpcom component embeds flite-1.4-release tts system in firefox or other mozilla based applications. Included are four voices, 3 U.S. male and 1 U.S. female speakers. It is implemented in the [Read2Me firefox addon] and requires firefox 3.x or greater because it uses the nsIThread components so that the speech does not block the UI. Although I have tested the flite component from xpcshell on firefox-2.0.x so there is some backward compatibility.

Flite-1.4-release has been modified so that it could be compiled/embedded in an xpcom component. Also a couple of functions were added to flite.c to control speech stop and pause.

Use:

From Javascript:

    var flite = Components.classes["@mozilla.org/Flite;1"].createInstance(Components.interfaces.nsIFlite);

    flite.initFlite(); // reads a short message in each installed voice, awb, kal(default voice), rms and slt 

    flite.sayThis("Some line of text"); // speaks the line of text using the default voice

    flite.sayThisVoice("Some line of text", "slt"); // speaks the line of text with the specified voice.

    flite.sayFile("/path/to/text/file.txt"); //speaks the contents of file.txt using the default voice.

    flite.sayFileVoice("/path/to/text/file.txt", "awb"); //speaks the contents of file.txt using the specified voice

    flite.unregisterVoice("stop"); //sending the string 'stop' will set the stopSpeaking flag in flite_stop_speech(int).

    flite.allowSpeech("speak"); //this sets the stopSpeaking flag to 'speak' to enable speaking.

    flite.unPauseSpeech("pause"); // sending the string 'pause' will pause speech until the 'pauseSpeech' flag is set in flite_pause_speech(int). Possible values are 'speak' and 'pause'

Methods:

    void initFlite();
    void sayThis(in string aPrefix);
    void sayThisVoice(in string aPrefix, in string aSpeaker);
    void sayFile(in string aPrefix);
    void sayFileVoice(in string aPrefix, in string aSpeaker);
    void unregisterVoice(in string aPrefix);
    void allowSpeech(in string aPrefix);
    void unPauseSpeech(in string aPrefix);

KioskWiki | KioskBrowser | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited December 31, 2009 1:12 pm (diff)
Search: