com.iSpeech
Class SpeechSynthesis

java.lang.Object
  extended by com.iSpeech.SpeechSynthesis

public class SpeechSynthesis
extends java.lang.Object

Contains methods used to synthesize speech from text. You can get a reference of this class by calling SpeechSynthesis.getInstance. An API key is required to use this class. You may obtain a free key from the following URL: http://www.ispeech.org/


Nested Class Summary
static interface SpeechSynthesis.SpeechSynthesisEvent
          Used to notify SpeechSynthesis events.
 
Method Summary
 void clearMetaAndOptionalCommands()
          Clears any associated meta and optional parameters.
 void copyMeta(MetaData metadata)
          Copies meta data information over to the speech synthesis object.
static SpeechSynthesis getInstance(java.lang.String ApiKey, boolean production)
          Gets an instance of the iSpeech Speech Synthesis class.
 int information()
          Gets the amount of credits remaining on this account.
 void setOptionalCommand(java.lang.String command, java.lang.String parameter)
          Specify additional parameters to send to the server.
 void setVoice(java.lang.String voice)
          Sets the voice to the specified variable.
 boolean speak(java.lang.String Text, int AudioPath, int VolumeLevel, SpeechSynthesis.SpeechSynthesisEvent speechSynthesisEvent)
          Converts text to speech and begins playing it as soon as it is ready.
 boolean speak(java.lang.String Text, SpeechSynthesis.SpeechSynthesisEvent speechSynthesisEvent)
          Converts text to speech and begins playing it as soon as it is ready.
 void stop()
          Stops the currently playing audio.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static SpeechSynthesis getInstance(java.lang.String ApiKey,
                                          boolean production)
                                   throws InvalidApiKeyException
Gets an instance of the iSpeech Speech Synthesis class. The ApiKey is only required on initial call to this method.

Parameters:
ApiKey - Your API key provided by iSpeech.
production - Set to true if you are deploying your application. Set to false if you are using the sandbox environment.
Throws:
java.lang.IllegalArgumentException - If the key is null or invalid.
InvalidApiKeyException

speak

public boolean speak(java.lang.String Text,
                     SpeechSynthesis.SpeechSynthesisEvent speechSynthesisEvent)
Converts text to speech and begins playing it as soon as it is ready. This method does not block.

Parameters:
Text - The text to convert into audio.
speechSynthesisEvent - A SpeechSynthesisEvent to receive messages and updates.

speak

public boolean speak(java.lang.String Text,
                     int AudioPath,
                     int VolumeLevel,
                     SpeechSynthesis.SpeechSynthesisEvent speechSynthesisEvent)
Converts text to speech and begins playing it as soon as it is ready. This method does not block.

Parameters:
Text - The text to convert into audio.
AudioPath - The audio path. see AudioPathControl. Set to -1 to not change the current audio path.
VolumeLevel - Sets the volume level for the audio. Possible values are 0 - 100. Set to -1 to not change the current volume level.
speechSynthesisEvent - A SpeechSynthesisEvent to receive messages and updates.
Throws:
java.io.IOException - If a general error occurs or could not connect to the server
java.lang.IllegalArgumentException
javax.microedition.media.MediaException - If the player object could not be created.
java.lang.InterruptedException
ApiException - If the server returned an error message. The exception will contain the server message. *

information

public int information()
                throws java.io.IOException,
                       ApiException
Gets the amount of credits remaining on this account. This method blocks.

Returns:
The amount of credits remaining or -1 if could not verify
Throws:
java.io.IOException - If a network exception occurs
ApiException - If the server returns an error

copyMeta

public void copyMeta(MetaData metadata)
              throws java.lang.Exception
Copies meta data information over to the speech synthesis object. This only copies, it does not maintain or use the class reference.

Parameters:
metadata -
Throws:
java.lang.Exception

setOptionalCommand

public void setOptionalCommand(java.lang.String command,
                               java.lang.String parameter)
Specify additional parameters to send to the server.


clearMetaAndOptionalCommands

public void clearMetaAndOptionalCommands()
Clears any associated meta and optional parameters.


stop

public void stop()
Stops the currently playing audio. This command is ignored if an advertisement is currently playing.


setVoice

public void setVoice(java.lang.String voice)
Sets the voice to the specified variable.

Parameters:
voice - Visit the iSpeech Developers center at http://www.ispeech.org or contact sales@ispeech.org to obtain a list of valid voices enabled for your account.