com.nuance.nmdp.speechkit
Interface Vocalizer


public interface Vocalizer

The Vocalizer object defines a server based text to speech implementation. This object is designed to be initialized with a language or voice and used for sequential speech requests. A single Vocalizer may be used for multiple speech requests.


Nested Class Summary
static interface Vocalizer.Listener
          The Vocalizer.Listener interface defines the callback methods called by a Vocalizer object during the speech synthesis process.
 
Method Summary
 void cancel()
          Cancels all speech requests.
 void setLanguage(java.lang.String language)
          Set the language for subsequent speech requests.
 void setListener(Vocalizer.Listener listener)
          Specify a new listener for the Vocalizer object.
 void setVoice(java.lang.String voice)
          Set the voice for subsequent speech requests.
 void speakMarkupString(java.lang.String markup, java.lang.Object context)
          Speaks the SSML string.
 void speakString(java.lang.String text, java.lang.Object context)
          Speaks the provided string.
 

Method Detail

setVoice

void setVoice(java.lang.String voice)
Set the voice for subsequent speech requests. Use this method to change the voice / language originally specified in SpeechKit.createVocalizerWithLanguage(java.lang.String, com.nuance.nmdp.speechkit.Vocalizer.Listener, android.os.Handler)() or SpeechKit.createVocalizerWithVoice(java.lang.String, com.nuance.nmdp.speechkit.Vocalizer.Listener, android.os.Handler)().

Parameters:
voice - The specific voice to use for speech. The list of supported voices sorted by language can be found at http://dragonmobile.nuancemobiledeveloper.com/faq.php.

setLanguage

void setLanguage(java.lang.String language)
Set the language for subsequent speech requests. Use this method to change the voice / language originally specified in SpeechKit.createVocalizerWithLanguage(java.lang.String, com.nuance.nmdp.speechkit.Vocalizer.Listener, android.os.Handler)() or SpeechKit.createVocalizerWithVoice(java.lang.String, com.nuance.nmdp.speechkit.Vocalizer.Listener, android.os.Handler)().

Parameters:
language - The language tag in the format of the ISO 639 language code, followed by an underscore "_", followed by the ISO 3166-1 country code. This language should correspond to the language of the text provided to the speakString(java.lang.String, java.lang.Object)() method. See http://dragonmobile.nuancemobiledeveloper.com/faq.php for a list of supported languages and voices.

speakString

void speakString(java.lang.String text,
                 java.lang.Object context)
Speaks the provided string.

This method will send a request to the text to speech server and return immediately. The text will be spoken as the server begins to stream audio, and Vocalizer.Listener methods will be called to indicate speech progress.

Parameters:
text - The string to be spoken.
context - A context object that will be passed back in the corresponding Vocalizer.Listener callbacks. May be null.

speakMarkupString

void speakMarkupString(java.lang.String markup,
                       java.lang.Object context)
Speaks the SSML string.

This method will perform exactly as the speakString(java.lang.String, java.lang.Object)() method with the exception that the markup within the markup string will be processed by the server according to SSML standards. This allows for more fine- grained control over the speech.

Parameters:
markup - The SSML string to be spoken.
context - A context object that will be passed back in the corresponding Vocalizer.Listener callbacks. May be null.

cancel

void cancel()
Cancels all speech requests.

This method will stop the current speech and cancel all pending speech requests. If any speech is playing, it will be stopped.


setListener

void setListener(Vocalizer.Listener listener)
Specify a new listener for the Vocalizer object.

This is especially useful when the object that created the original listener is no longer valid (e.g. an Activity has been destroyed and recreated by the Android OS due to the screen orientation changing). This method helps to ensure that subsequent callbacks will be processed by an up-to-date listener.

Parameters:
listener - The Vocalizer.Listener for vocalization progress. The listener will receive notifications when speech starts and stops, or when a SpeechError occurs.