Acapela TTS module for Titanium
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.
returns an object initialized for text to speech commands
var TTS = ttsModule.createTTS();
sets the TTS object with your license that has been provided by Acapella Returns boolean true if succesful, false if not succesful.
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
});
returns an array of strings containing the names of the installed voices at the provided directories
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.
Loads the selected voice retrieved from getVoicesList() Returns 0 if successful or values less than zero if unsuccessful
TTS.load({
'voice':voices[0] // Required - voices array is created from getVoicesList() function
});
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
TTS.speak({
'text':'A simple string to speak' // Required - text to be spoken using TTS
});
Generates a wav file with the given text at the provided path filename Will stop any current TTS speaking that is in progress
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
});
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
TTS.queueText({
'text':'This text has been queued after text currently being spoken' // Required
});
Stops the current TTS speaking Returns 0 if successful, less than 0 if unsuccessful
TTS.stop();
Pauses the current TTS speaking Returns 0 if successful, less than 0 if unsuccessful
TTS.pause();
Resumes the current TTS speaking if it has been paused Returns 0 if successful, less than 0 if unsuccessful
TTS.resume();
Polls the TTS object if it is currently speaking text Returns boolean, true if speaking, false otherwise
if(TTS.isSpeaking())
Ti.API.info('Speaking');
else
Ti.API.info('Not Speaking');
Sets the pitch of the the currently loaded voice, float value from 50 to 200 Returns 0 if successful, less than 0 if unsuccessful
TTS.setPitch({
'pitch':'120' // Required - float value for pitch as a string
});
Sets the speech rate of the currently loaded voice, float value from 50 to 200 Returns 0 if successful, less than 0 if unsuccessful
TTS.setSpeechRate({
'speechRate':'50' // Required - float value for speech rate as a string
});
Returns a string with the language of the currently loaded voice
Ti.APP.info('Currently speaking in '+TTS.getLanguage());
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
TTS.shutdown();
Returns the value of the last error that was encountered, errors are values that are returnted that are less than 0 Error values Mean
Ti.API.info('Last enocountered error was: '+TTS.getLastError());
Returns the version of Acapela Library
Ti.API.info('Acapela Library version: '+TTS.getVersion());