|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.iSpeech.SpeechRecognizer
public class SpeechRecognizer
Contains methods to recognize spoken audio and convert free form speech into text.
Nested Class Summary | |
---|---|
static interface |
SpeechRecognizer.SpeechRecognizerEvent
Used to notify when the recording state changes |
class |
SpeechRecognizer.SpeechResult
Contains the text and the confidence rating for the conversion, which is a float 0.0 to 1.0 |
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 |
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. |
void |
copyMeta(MetaData metadata)
Copies meta data information over to the speech recognizer object. |
static SpeechRecognizer |
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. |
boolean |
startRecordAndNotify(boolean recordBluetooth,
long notifyInMillisec,
SpeechRecognizer.SpeechRecognizerEvent speechRecognizerEvent)
Start recording. |
SpeechRecognizer.SpeechResult |
stopRecord()
Stops the recording process and returns a SpeechRecognizer.SpeechResult . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int FREEFORM_DISABLED
public static final int FREEFORM_SMS
public static final int FREEFORM_VOICEMAIL
public static final int FREEFORM_DICTATION
public static final int FREEFORM_MESSAGE
public static final int FREEFORM_INSTANT_MESSAGE
public static final int FREEFORM_TRANSCRIPT
public static final int FREEFORM_MEMO
Method Detail |
---|
public void setFreeForm(int freeFormType)
public void setOptionalCommand(java.lang.String command, java.lang.String parameter)
public void clearMetaAndOptionalCommands()
public void copyMeta(MetaData metadata) throws java.lang.Exception
metadata
-
java.lang.Exception
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.
aliasName
- The name of your alias for referencing inside of your
commands.phrases
- The list of phrases for this alias.public void clear()
SpeechRecognizer
object.
public void addCommand(java.lang.String[] commandPhrases)
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.
commandPhrases
- An array containing your command phrasespublic void addCommand(java.lang.String commandPhrase)
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.
commandPhrase
- A command phrasepublic void cancelRecord()
public SpeechRecognizer.SpeechResult stopRecord() throws java.lang.IllegalArgumentException, ApiException, InvalidApiKeyException
SpeechRecognizer.SpeechResult
.
SpeechRecognizer.SpeechResult
with the text string of the audio and a
float containing the estimated confidence.
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.public boolean startRecordAndNotify(boolean recordBluetooth, long notifyInMillisec, SpeechRecognizer.SpeechRecognizerEvent speechRecognizerEvent) throws java.lang.Exception
recordBluetooth
- Record from a connected bluetooth headset instead of the
devicenotifyInMillisec
- The amount of time in milliseconds to record audio. After this
time expires, a RECORDING_COMPLETE event will be triggered.speechRecognizerEvent
- A SpeechRecognizerEvent to receive status updates and messages.
java.lang.Exception
public static SpeechRecognizer getInstance(java.lang.String ApiKey, boolean production) throws InvalidApiKeyException
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.
InvalidApiKeyException
public void setLanguage(java.lang.String localeCode)
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.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |