tts Module

Description

Acapela TTS module for Titanium

Accessing the tts Module

To access this module from JavaScript, you would do the following:

var ttsModule = require('com.dmarie.tts');

The ttsModule variable is a reference to the Module object.

Reference

createTTS()

returns an object initialized for text to speech commands

Usage

var TTS = ttsModule.createTTS();

TTS.setLicense({options:object})

sets the TTS object with your license that has been provided by Acapella Returns boolean true if succesful, false if not succesful.

Usage

var success = TTS.setLicense({
    'userId':'0x11111111',      // Required - Your userId as a string, Hex and long format both work
    'password':'0x11111111',    // Required - Similar to userId but your password
    'license':'your license'    // Required - Your license string
});

TTS.getVoicesList({options:object})

returns an array of strings containing the names of the installed voices at the provided directories

Usage

var dirArray = new Array('sdcard/myttsapp/voices');

var voices = TTS.getVoicesList({
    'voiceDirPaths':dirArray  // Required - Array of strings point to directories where voices are installed
});

// Voices must be loaded in folders under the specified voices folder
// For example:
//     /sdcard/myttsapp/voices/usenglish-heather-hqm-22khz
//     /sdcard/myttsapp/voices/usenglish-ryan-hqm-22khz
//     etc.

TTS.load({options:object})

Loads the selected voice retrieved from getVoicesList() Returns 0 if successful or values less than zero if unsuccessful

Usage

TTS.load({
    'voice':voices[0]   // Required - voices array is created from getVoicesList() function
});

TTS.speak({options:object})

Speaks the the string passed in, using the selected voice from load() function Returns 0 if successful or vaules less than zero if unsuccessful Will stop any currentl TTS speaking if any

Usage

TTS.speak({
    'text':'A simple string to speak'  // Required - text to be spoken using TTS
});

TTS.sysnthesizeToFile({options:object})

Generates a wav file with the given text at the provided path filename Will stop any current TTS speaking that is in progress

Usage

TTS.sysnthesizeToFile({
    'text':'Put this text into a wav file for me.',   // Required - Spoken text to be placed into file
    'fileName':'sdcard/myttsapp/generatedaudio.wav'   // Required - Filename and path for generated wav file
});

TTS.queueText({options:object})

Queues the given text to the current speaking TTS, if TTS is currently not speaking, will start speaking with given text returns values greater than or equal to 0 if successful, and values less than 0 if unsuccessful

Usage

TTS.queueText({
    'text':'This text has been queued after text currently being spoken' // Required
});

TTS.stop()

Stops the current TTS speaking Returns 0 if successful, less than 0 if unsuccessful

Usage

TTS.stop();

TTS.pause()

Pauses the current TTS speaking Returns 0 if successful, less than 0 if unsuccessful

Usage

TTS.pause();

TTS.resume()

Resumes the current TTS speaking if it has been paused Returns 0 if successful, less than 0 if unsuccessful

Usage

TTS.resume();

TTS.isSpeaking()

Polls the TTS object if it is currently speaking text Returns boolean, true if speaking, false otherwise

Usage

if(TTS.isSpeaking())
    Ti.API.info('Speaking');
else
    Ti.API.info('Not Speaking');

TTS.setPitch({options:object})

Sets the pitch of the the currently loaded voice, float value from 50 to 200 Returns 0 if successful, less than 0 if unsuccessful

Usage

TTS.setPitch({
    'pitch':'120'   // Required - float value for pitch as a string
});

TTS.setSpeechRate({options:object})

Sets the speech rate of the currently loaded voice, float value from 50 to 200 Returns 0 if successful, less than 0 if unsuccessful

Usage

TTS.setSpeechRate({
    'speechRate':'50'     // Required - float value for speech rate as a string
});

TTS.getLanguage()

Returns a string with the language of the currently loaded voice

Usage

Ti.APP.info('Currently speaking in '+TTS.getLanguage());

TTS.shutdown()

Unloads and cleans up the TTS object, after this is called the TTS object is no longer useable Returns 0 if successful, values less than 0 if unsuccessful

Usage

TTS.shutdown();

TTS.getLastError()

Returns the value of the last error that was encountered, errors are values that are returnted that are less than 0 Error values Mean

Usage

Ti.API.info('Last enocountered error was: '+TTS.getLastError());

TTS.getVersion()

Returns the version of Acapela Library

Usage

Ti.API.info('Acapela Library version: '+TTS.getVersion());