com.iSpeech
Class iSpeechRecognizer

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

public class iSpeechRecognizer
extends java.lang.Object

Contains methods to recognize spoken audio and convert free form speech into text.


Nested Class Summary
static interface iSpeechRecognizer.SpeechRecognizerEvent
          Used to notify when the recording state changes
 
Field Summary
static int FREEFORM_DICTATION
          Free form dictation, such as a written document
static int FREEFORM_DISABLED
          Disable free form speech recognition.
static int FREEFORM_INSTANT_MESSAGE
          A message for an instant message client
static int FREEFORM_MEMO
          A memo or a list of items
static int FREEFORM_MESSAGE
          A message addressed to another person.
static int FREEFORM_SMS
          A SMS or TXT message.
static int FREEFORM_TRANSCRIPT
          General transcription
static int FREEFORM_VOICEMAIL
          A voice mail transcription
static java.lang.String version
           
 
Method Summary
 void addAlias(java.lang.String aliasName, java.lang.String[] phrases)
           Adds an alias to use inside of a command.
 void addCommand(java.lang.String commandPhrase)
          Adds a new command phrase.
 void addCommand(java.lang.String[] commandPhrases)
          Adds a new command phrase.
 void cancelRecord()
          Cancels a recording in progress and dismisses the current prompt if one is visible.
 void clear()
          Clears all commands and aliases from this SpeechRecognizer object.
 void clearMetaAndOptionalCommands()
          Clears any associated meta and optional parameters.
static iSpeechRecognizer getInstance(java.lang.String ApiKey, boolean production)
          Gets an instance of the iSpeech SpeechRecognizer class.
 void setFreeForm(int freeFormType)
          Set to free form recognition.
 void setLanguage(java.lang.String localeCode)
          Set the speech recognition language.
 void setOptionalCommand(java.lang.String command, java.lang.String parameter)
          Specify additional parameters to send to the server.
 SpeechResult startFileRecognize(java.lang.String mimeType, java.io.File file, iSpeechRecognizer.SpeechRecognizerEvent speechRecognizerEvent)
           
 java.io.OutputStream startStreamingRecognize(java.lang.String mimeType, iSpeechRecognizer.SpeechRecognizerEvent speechRecognizerEvent)
           
 SpeechResult stopRecord()
          Stops the recording process and returns a SpeechResult.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FREEFORM_DISABLED

public static final int FREEFORM_DISABLED
Disable free form speech recognition.

See Also:
Constant Field Values

FREEFORM_SMS

public static final int FREEFORM_SMS
A SMS or TXT message.

See Also:
Constant Field Values

FREEFORM_VOICEMAIL

public static final int FREEFORM_VOICEMAIL
A voice mail transcription

See Also:
Constant Field Values

FREEFORM_DICTATION

public static final int FREEFORM_DICTATION
Free form dictation, such as a written document

See Also:
Constant Field Values

FREEFORM_MESSAGE

public static final int FREEFORM_MESSAGE
A message addressed to another person.

See Also:
Constant Field Values

FREEFORM_INSTANT_MESSAGE

public static final int FREEFORM_INSTANT_MESSAGE
A message for an instant message client

See Also:
Constant Field Values

FREEFORM_TRANSCRIPT

public static final int FREEFORM_TRANSCRIPT
General transcription

See Also:
Constant Field Values

FREEFORM_MEMO

public static final int FREEFORM_MEMO
A memo or a list of items

See Also:
Constant Field Values

version

public static java.lang.String version
Method Detail

getInstance

public static iSpeechRecognizer getInstance(java.lang.String ApiKey,
                                            boolean production)
                                     throws InvalidApiKeyException
Gets an instance of the iSpeech SpeechRecognizer class. The ApiKey parameter 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:
InvalidApiKeyException

startStreamingRecognize

public java.io.OutputStream startStreamingRecognize(java.lang.String mimeType,
                                                    iSpeechRecognizer.SpeechRecognizerEvent speechRecognizerEvent)
                                             throws java.lang.Exception
Parameters:
mimeType - Example amr audio/amr mp3 audio/mpeg
speechRecognizerEvent - A SpeechRecognizerEvent to receive status updates and messages.
Returns:
an Outputstream The audio data should be written to this stream.
Throws:
java.lang.Exception

startFileRecognize

public SpeechResult startFileRecognize(java.lang.String mimeType,
                                       java.io.File file,
                                       iSpeechRecognizer.SpeechRecognizerEvent speechRecognizerEvent)
                                throws java.lang.Exception
Parameters:
mimeType - Example amr audio/amr mp3 audio/mpeg
file - input audio file
speechRecognizerEvent - A SpeechRecognizerEvent to receive status updates and messages.
Returns:
SpeechResult
Throws:
java.lang.Exception

cancelRecord

public void cancelRecord()
Cancels a recording in progress and dismisses the current prompt if one is visible.


stopRecord

public SpeechResult stopRecord()
                        throws java.lang.IllegalArgumentException,
                               ApiException,
                               InvalidApiKeyException
Stops the recording process and returns a SpeechResult.

Returns:
SpeechResult with the text string of the audio and a float containing the estimated confidence.
Throws:
ApiException - The server could not process your command and an API exception occurred.
java.lang.IllegalArgumentException - if your command list is invalid or your commands are too complex. Note: You can only a maximum of two aliases per command.
InvalidApiKeyException - if your API key is invalid.

setFreeForm

public void setFreeForm(int freeFormType)
Set to free form recognition. Will not use any command or alias list. Your API key must be provisioned to use this feature. One of the SpeechRecognizer.FREEFORM_ values. Most developer accounts can use FREEFORM_DICTATION as a parameter.


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.


addAlias

public void addAlias(java.lang.String aliasName,
                     java.lang.String[] phrases)

Adds an alias to use inside of a command. You can reference the added alias using %ALIASNAME% from within a command. Alias names are automatically capitalized. Note: You can only a maximum of two aliases per command.

Example:

 SpeechRecognizer rec = SpeechRecognizer.getInstance("APIKEY");
 String[] names = new String[] { "jane", "bob", "john" };
 rec.addAlias("NAMES", names);
 rec.addCommand("call %NAMES%");
 

The user can now speak "call john" and it will be recognized correctly.

Parameters:
aliasName - The name of your alias for referencing inside of your commands.
phrases - The list of phrases for this alias.

clear

public void clear()
Clears all commands and aliases from this SpeechRecognizer object.


addCommand

public void addCommand(java.lang.String[] commandPhrases)
Adds a new command phrase. Note: You can only use two aliases per command.

Example:

 SpeechRecognizer rec = SpeechRecognizer.getInstance("APIKEY");
 String commands = new String(){"yes","no"};
 rec.addCommand(commands);
 

The user can now speak "Yes" or "No" and it will be recognized correctly.

Parameters:
commandPhrases - An array containing your command phrases

addCommand

public void addCommand(java.lang.String commandPhrase)
Adds a new command phrase. Note: You can only use two aliases per command.

Example:

 SpeechRecognizer rec = SpeechRecognizer.getInstance("APIKEY");
 rec.addCommand("yes");
 rec.addCommand("no");
 

The user can now speak "Yes" or "No" and it will be recognized correctly.

Parameters:
commandPhrase - A command phrase

setLanguage

public void setLanguage(java.lang.String localeCode)
Set the speech recognition language.

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