public class SpeechRecognizer extends Object implements Recognizer
Modifier and Type | Method and Description |
---|---|
void |
addAlias(String name,
String[] values)
Adds an alias to use inside of a command.
|
void |
addCommand(String phrase)
Adds a new command phrase.
|
void |
addCommand(String[] commandPhrases)
Adds a command phrases.
|
void |
addMeta(MetaType type,
String value)
Add meta value to synthesizer
|
void |
addOptionalCommand(String command,
String parameter)
Specify additional parameters to send to the server.
|
void |
cancelProcessing()
Cancels the processing of the recorded voice data i.e.
|
void |
cancelRecord()
Cancels voice recording that is in progress
|
void |
clearAlias()
Clear all aliases
|
void |
clearCommand()
Clears all commands
|
void |
clearOptionalCommand()
Clear all optional commands
|
FreeformType |
getFreeForm()
Get current free form value
|
static SpeechRecognizer |
getInstance(Context context)
Gets an instance of the iSpeech SpeechRecognizer class.
|
boolean |
isRunning()
Test this to determine if this is still running
|
void |
setChime(boolean isOn)
Disable or enable the audio chime
|
void |
setFreeForm(FreeformType freeFormType)
Set to free form recognition.
|
void |
setLocale(String locale)
Sets to Locale for recognizer.
|
void |
setModel(String model)
Sets the language model
|
void |
setSilenceDetection(boolean silenceDetection)
Enables and disables silence detection.
|
void |
setTimeout(int timeout)
Set the maximum recording time in milliseconds
|
void |
startRecord(SpeechRecognizerEvent speechRecognizerEvent)
Starts recording audio for SpeechRecognition
|
void |
stopRecord()
Stops the recording process
|
void |
toDisableTheDialogContact_salesATiSpeechDOTorg()
To disable loading dialogs and prompts please contact sales@iSpeech.org
|
public static SpeechRecognizer getInstance(Context context) throws InvalidApiKeyException
context
- Context
objectisProduction
- Set to true to specify that this application is in production mode. Set to false to use the sandbox servers. Your key must be provisioned for production use in order to deploy your application. Note: This flag is global.InvalidApiKeyException
public void startRecord(SpeechRecognizerEvent speechRecognizerEvent) throws BusyException, NoNetworkException
startRecord
in interface Recognizer
BusyException
- If a player could not be createdNoNetworkException
public void setSilenceDetection(boolean silenceDetection)
silenceDetection
- boolean
set to true to enable silence detection, and false to disable silence detection.public void stopRecord()
stopRecord
in interface Recognizer
ApiException
- The server could not process your command and an API
exception occurred.public void cancelRecord()
cancelRecord
in interface Recognizer
public void toDisableTheDialogContact_salesATiSpeechDOTorg()
public void cancelProcessing()
cancelProcessing
in interface Recognizer
public void clearCommand()
clearCommand
in interface Recognizer
public void addCommand(String[] commandPhrases)
Example:
SpeechRecognizer rec = SpeechRecognizer.getInstance("APIKEY"); rec.addCommand(new String[]{"yes","no"};);
The user can now speak "Yes" or "No" and it will be recognized correctly.
addCommand
in interface Recognizer
commandPhrases
- An array containing your command phrasespublic void setFreeForm(FreeformType freeFormType)
FreeformType
values.setFreeForm
in interface Recognizer
public FreeformType getFreeForm()
getFreeForm
in interface Recognizer
public boolean isRunning()
isRunning
in interface Recognizer
public void addAlias(String name, String[] values)
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 have 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.
addAlias
in interface Recognizer
name
- The name of your alias for referencing inside of your
commands.values
- The list of phrases for this alias.public void clearAlias()
clearAlias
in interface Recognizer
public void setTimeout(int timeout)
timeout
- public void addMeta(MetaType type, String value)
addMeta
in interface Recognizer
type
- value
- public void clearOptionalCommand()
clearOptionalCommand
in interface Recognizer
public void addOptionalCommand(String command, String parameter)
addOptionalCommand
in interface Recognizer
public void addCommand(String phrase)
Recognizer
addCommand
in interface Recognizer
phrase
- Your command phrasepublic void setModel(String model)
Recognizer
setModel
in interface Recognizer
public void setLocale(String locale)
SpeechRecognizer recognizer;
recognizer = SpeechRecognizer.getInstance(this);
recognizer.setLocale("en-US"); //set to US-English
setLocale
in interface Recognizer
locale
- currently implemented locales:
* Catalan (Catalan) (ca-ES) Chinese (Taiwan) (zh-TW) Danish (Denmark) (da-DK) English (United States) (en-US) Finnish (Finland) (fi-FI) French (France) (fr-FR) Italian (Italy) (it-IT) Japanese (Japan) (ja-JP) Korean (Korea) (ko-KR) Dutch (Netherlands) (nl-NL) Norwegian (Norway) (nb-NO) Polish (Poland) (pl-PL) Portuguese (Brazil) (pt-BR) Russian (Russia) (ru-RU) Swedish (Sweden) (sv-SE) Chinese (People's Republic of China) (zh-CN) English (United Kingdom) (en-GB) Spanish (Mexico) (es-MX) Portuguese (Portugal) (pt-PT) Chinese (Hong Kong S.A.R.) (zh-HK) English (Australia) (en-AU) Spanish (Spain) (es-ES) French (Canada) (fr-CA) English (Canada) (en-CA)
public void setChime(boolean isOn)
Recognizer
setChime
in interface Recognizer