Simple tts (text-to-speech) module for Titanium SDK. Allows you to say a sentence and write it to a wav file.
- init()
- init( engine: string ) - Init specific TTS Engine if available
- speak({ text: string, uid: string, volume: float, pan: float, flush: boolean }) - There is a character limit (of 4000 characters) per speak method. The exact maximum allowed length can be read from the bufferlen property.
- synthesizeToFile({ text: string, filename: string, uid: string, volume: float, pan: float, blob: boolean })
- stop()
- shutdown()
- setup({ voice: string, language: string, volume: float, pan: float, speed: float, pitch: float, flush: boolean, uid: boolean, filename: string, blob: boolean}) - Default configuration for Speaker
- getVoices( filter: string ) - Returns a string with voices separated by a
|
. Optionally you can pass in a string to filter on voices names, for examplede-de
to only get German voices. - getVoiceList( filter: string )
- getEngines()
- getEngineList()
- getEnginePackageList() - The Engines' Package Name for init(engine) and setEngine(engine).
- getLanguages()
- getLanguageList()
- getVoiceFeatures( voice: string )
- initSilent() - Init without events emitter (except for the init event once).
- emitEvents() - Start events emitter.
- separateSpeaker() - Return a new Instance of TTS ( Experimental feature, marked as Deprecated to notify it).
- setEngine( engine: string ) - Deprecated, because do not emit the init event when the engine is ready. Use init(engine) instead.
- pitch (setter): float
- speed (setter): float
- voices (getter): string. Returns a string with voices separated by a
|
. Optional you can pass inde-de
to only get German voices. - voice (setter): string
- language (setter): string. e.g.
de
oren
- speaking (getter): boolean. (DO NOT RELY ON THIS ON INIT! You could need to start flushing the queque after init. )
- bufferlen (getter): int. Maximum length of the text string to read (Usually 4000 character)
- init: when TTS is ready - CallBack({ status: int })
- stop: when TTS stops - CallBack({ uid: string, interrupted: boolean })
- error: when TTS fails - CallBack({ uid: string, code: int })
- done: when TTS has done (Could include a Blob for synthesizeToFile)- CallBack({ uid: string, blob: Blob })
Voices' names are in the format:
<lang>-<region>-x-<flags>-<type>
Where:
- <lang> and <region> are 2 char ISO codes (i.e.
it
,de
,en
) - <flags> is a usually 3 char voice description
- <type> can be
local
(on device voice),network
(on cloud voice) orlanguage
(not specified)
Engines' names from getEngines and getEngineList are in the format:
<name> @<package>
Where:
- <name> is the engine label name
- <package> is the engine pakage name for setEngine(engine) and init(engine)
Engines' Package Names List can be retrived from getEnginePackageList().
- volume: Float, Range [ 0 , 1 ], Default 1.
- pan: Float, Range [ -1 , 1 ], Default 0.
- pitch: Float, Default 1, lower for lower voice tone, greater to increase.
- speed: Float, Default 1, 2 double speed, 0.5 half speed.
- flush: Boolean, FLUSH the speak queque or ADD the text to speak to the queue (only for speak method).
- blob: Retrive Blob to done event (only for synthesizeToFile method).
- filename: File name (only for synthesizeToFile method).
- uid: Utterance ID.
- There is a limit of bufferlen (4000) characters for each call to speak and synthesizeToFile.
- Sometimes after the init event a queque FLUSH could be needed to start speaking (especially if speaking is true).
const tts = require("ti.tts");
const win = Ti.UI.createWindow();
tts.addEventListener("init", function(e) {
tts.speak({text:"Hello World!", flush:true});
});
win.addEventListener("open", function() {
tts.init();
});
win.addEventListener("close", function() {
tts.shutdown();
});
win.open();
- Michael Gangolf (@MichaelGangolf / Web)
- T. A. (@TA / Web)