Unity Android TTS Plugin
 All Classes Functions
Classes | Public Types | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
TTSManager Class Reference

Unity TTS manager. More...

Classes

class  Locale
 

Public Types

enum  STREAM {
  Alarm = 4, DTMF = 8, Music = 3, Notification = 5,
  Ring = 2
}
 

Static Public Member Functions

static void Initialize (string gameObjectName, string callbackMethodName)
 Initialize the TextToSpeech Manager. More...
 
static void Speak (string text, bool addToQueue, STREAM stream=STREAM.Music, float volume=1f, float pan=0f, string gameObjectName=null, string callbackMethodName=null, string id=null)
 Speaks the string using the specified queuing strategy and speech parameters. This method is asynchronous, i.e. the method just adds the request to the queue of TTS requests and then returns. The synthesis might not have finished (or even started!) at the time when this method returns. More...
 
static void PlaySilence (int durationInMs, bool addToQueue, string gameObjectName=null, string callbackMethodName=null, string id=null)
 Plays silence for the specified amount of time using the specified queue mode. More...
 
static void SynthesizeToFile (string text, string filename, string gameObjectName=null, string callbackMethodName=null, string id=null)
 Synthesizes to file. The application must have the WRITE_EXTERNAL_STORAGE permission (Write Access set to External in the Unity player settings). More...
 
static void Stop ()
 Interrupts the current speech and discards others in the queue. More...
 
static void Shutdown ()
 Releases the resources used by the TextToSpeech engine. More...
 
static bool IsInitialized ()
 Determines if is initialized. More...
 
static bool IsSpeaking ()
 Checks whether the TTS engine is busy speaking. More...
 
static bool IsLanguageAvailable (Locale locale)
 Checks if the specified language as represented by the Locale is available and supported. More...
 
static List< LocaleGetAvailableLanguages ()
 Returns all languages supported by the current device. More...
 
static bool SetLanguage (Locale locale)
 Sets the text-to-speech language. The TTS engine will try to use the closest match to the specified language as represented by the Locale, but there is no guarantee that the exact same Locale will be used. Use isLanguageAvailable(Locale) to check the level of support before choosing the language to use. More...
 
static void SetPitch (float pitch)
 Sets the speech pitch for the TextToSpeech engine. More...
 
static void SetSpeechRate (float rate)
 Sets the speech rate. This has no effect on any pre-recorded speech. More...
 

Public Attributes

const int SUCCESS = 0
 
const int ERROR = -1
 

Static Public Attributes

static readonly Locale CHINESE = new Locale("Chinese", "zh")
 
static readonly Locale ENGLISH = new Locale("English", "en")
 
static readonly Locale FRENCH = new Locale("French", "fr")
 
static readonly Locale GERMAN = new Locale("German", "de")
 
static readonly Locale ITALIAN = new Locale("Italian", "it")
 
static readonly Locale JAPANESE = new Locale("Japanese", "ja")
 
static readonly Locale KOREAN = new Locale("Korean", "ko")
 
static readonly Locale[] Locales
 

Detailed Description

Unity TTS manager.

Member Function Documentation

static List<Locale> TTSManager.GetAvailableLanguages ( )
static

Returns all languages supported by the current device.

Returns
The available languages.
static void TTSManager.Initialize ( string  gameObjectName,
string  callbackMethodName 
)
static

Initialize the TextToSpeech Manager.

Parameters
gameObjectNameGame Object name holding the callback method.
callbackMethodNameCallback method name.
static bool TTSManager.IsInitialized ( )
static

Determines if is initialized.

Returns
true if is initialized; otherwise, false.
static bool TTSManager.IsLanguageAvailable ( Locale  locale)
static

Checks if the specified language as represented by the Locale is available and supported.

Returns
true if is language available the specified locale; otherwise, false.
Parameters
localeThe Locale describing the language to be used.
static bool TTSManager.IsSpeaking ( )
static

Checks whether the TTS engine is busy speaking.

Returns
true if is speaking; otherwise, false.
static void TTSManager.PlaySilence ( int  durationInMs,
bool  addToQueue,
string  gameObjectName = null,
string  callbackMethodName = null,
string  id = null 
)
static

Plays silence for the specified amount of time using the specified queue mode.

Parameters
durationInMsDuration in ms of the silence.
addToQueueThe queuing strategy to use. If true, the new entry is added at the end of the playback queue. Otherwise, all entries in the playback queue (text to be synthesized) are dropped and replaced by the new entry.
gameObjectNameGame Object name holding the callback name. (optional)
callbackMethodNameMethod to call when the entry is played and completed. (optional)
idIdentifier of this entry. (optional)
static bool TTSManager.SetLanguage ( Locale  locale)
static

Sets the text-to-speech language. The TTS engine will try to use the closest match to the specified language as represented by the Locale, but there is no guarantee that the exact same Locale will be used. Use isLanguageAvailable(Locale) to check the level of support before choosing the language to use.

Returns
true, if language was set, false otherwise.
Parameters
localeThe Locale describing the language to be used.
static void TTSManager.SetPitch ( float  pitch)
static

Sets the speech pitch for the TextToSpeech engine.

Parameters
pitchSpeech pitch. 1.0 is the normal pitch, lower values lower the tone of the synthesized voice, greater values increase it.
static void TTSManager.SetSpeechRate ( float  rate)
static

Sets the speech rate. This has no effect on any pre-recorded speech.

Parameters
rateSpeech rate. 1.0 is the normal speech rate, lower values slow down the speech (0.5 is half the normal speech rate), greater values accelerate it (2.0 is twice the normal speech rate).
static void TTSManager.Shutdown ( )
static

Releases the resources used by the TextToSpeech engine.

static void TTSManager.Speak ( string  text,
bool  addToQueue,
STREAM  stream = STREAM.Music,
float  volume = 1f,
float  pan = 0f,
string  gameObjectName = null,
string  callbackMethodName = null,
string  id = null 
)
static

Speaks the string using the specified queuing strategy and speech parameters. This method is asynchronous, i.e. the method just adds the request to the queue of TTS requests and then returns. The synthesis might not have finished (or even started!) at the time when this method returns.

Parameters
textThe string of text to be spoken.
addToQueueThe queuing strategy to use. If true, the new entry is added at the end of the playback queue. Otherwise, all entries in the playback queue (text to be synthesized) are dropped and replaced by the new entry.
streamSpecify the audio stream type to be used when speaking text.
volumeSpecify the speech volume relative to the current stream type volume used when speaking text. Volume is specified as a float ranging from 0 to 1 where 0 is silence, and 1 is the maximum volume (the default behavior).
panSpecify how the speech is panned from left to right when speaking text. Pan is specified as a float ranging from -1 to +1 where -1 maps to a hard-left pan, 0 to center (the default behavior), and +1 to hard-right.
gameObjectNameGame Object name holding the callback name. (optional)
callbackMethodNameMethod to call when the entry is played and completed. (optional)
idIdentifier of this entry. (optional)
static void TTSManager.Stop ( )
static

Interrupts the current speech and discards others in the queue.

static void TTSManager.SynthesizeToFile ( string  text,
string  filename,
string  gameObjectName = null,
string  callbackMethodName = null,
string  id = null 
)
static

Synthesizes to file. The application must have the WRITE_EXTERNAL_STORAGE permission (Write Access set to External in the Unity player settings).

Parameters
textThe text that should be synthesized.
filenameAbsolute file filename to write the generated audio data to.It should be something like "/sdcard/myappsounds/mysound.wav".
gameObjectNameGame Object name holding the callback name. (optional)
callbackMethodNameMethod to call when the entry is played and completed. (optional)
idIdentifier of this entry. (optional)

The documentation for this class was generated from the following file: