Skip to content
forked from m1ga/ti.tts

Text-to-speech module for Titanium SDK

License

Notifications You must be signed in to change notification settings

Informate/ti.tts

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Text-to-speech module for Titanium SDK (Android)

Simple tts (text-to-speech) module for Titanium SDK. Allows you to say a sentence and write it to a wav file.

Methods

  • 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 example de-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.

Properties

  • pitch (setter): float
  • speed (setter): float
  • voices (getter): string. Returns a string with voices separated by a |. Optional you can pass in de-de to only get German voices.
  • voice (setter): string
  • language (setter): string. e.g. de or en
  • 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)

Events

  • 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

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) or language (not specified)

Engines' names

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().

Setup Attributes

  • 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.

Notes

  • 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).

Example

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();

Authors

Buy Me A Coke donate button

About

Text-to-speech module for Titanium SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 93.4%
  • JavaScript 6.6%