ISSpeechRecognition Class Reference
| Inherits from | NSObject |
| Declared in | ISSpeechRecognition.h |
Tasks
Getting and Setting the Delegate
-
delegateThe delegate of a speech recognition object.
property
Configuration Properties
-
localeSets the locale to use for speech recognition.
property -
modelAllows you to set a custom language model for speech recognition.
property -
freeformTypeThe type of model to use when trascribing audio. Defaults to
propertyISFreeFormTypeDictation. -
silenceDetectionEnabledWhether silence detection should be used to automatically detect when someone’s done talking.
property
Detecting Audio Input
-
+ audioInputAvailableReturns whether audio input is available for speech recognition. You can check this before creating an instance of
ISSpeechRecognition, as well as to dynamically update your UI with what you can do.
Aliases and Commands
-
– addAlias:forItems:Adds a list of items as an alias.
-
– addCommand:Adds a command.
-
– addCommands:Add multiple commands from an array.
-
– resetCommandsAndAliasesClears any command or alias lists on this speech recognition object.
Listening and Recognizing
-
– listen:Start an untimed listen.
-
– finishListenAndStartRecognizeIf you’re running an untimed listen, or if you want to cut a timed listen short, call this method to tell the SDK to stop listening for audio, and finish up transcribing.
-
– listenAndRecognizeWithTimeout:error:Starts a timed listen. After a set timeout, the SDK will stop listening for audio and will start to transcribe it.
-
– listenWithHandler:Start an untimed listen.
-
– listenAndRecognizeWithTimeout:handler:Starts a timed listen. After a set timeout, the SDK will stop listening for audio and will start to transcribe it.
-
– cancelCancels an in progress speech recognition action.
Properties
delegate
The delegate of a speech recognition object.
@property (nonatomic, unsafe_unretained) id<ISSpeechRecognitionDelegate> delegateDiscussion
The delegate must adopt the ISSpeechRecognitionDelegate protocol.
Declared In
ISSpeechRecognition.hfreeformType
The type of model to use when trascribing audio. Defaults to ISFreeFormTypeDictation.
@property (nonatomic, assign) ISFreeFormType freeformTypeDeclared In
ISSpeechRecognition.hlocale
Sets the locale to use for speech recognition.
@property (nonatomic, copy) NSString *localeDiscussion
Most of the time, the value passed is a ISO country code. To get our supported ISOs, consult “Freeform Dictation Languages” under “Speech Recognition Settings” when viewing details about a specific key.
Declared In
ISSpeechRecognition.hClass Methods
audioInputAvailable
Returns whether audio input is available for speech recognition. You can check this before creating an instance of ISSpeechRecognition, as well as to dynamically update your UI with what you can do.
+ (BOOL)audioInputAvailableReturn Value
Returns whether audio input is available.
Declared In
ISSpeechRecognition.hInstance Methods
addAlias:forItems:
Adds a list of items as an alias.
- (void)addAlias:(NSString *)alias forItems:(NSArray *)itemsParameters
- alias
The string to use for the alias key.
- items
The array of items to be substituted for the alias.
Discussion
Think of using an alias list as a way of doing a regular expression. For example, if you want to use a regular expression to match “call joe”, “call charlie”, or “call ben”, then it would be call (joe|charlie|ben). Similarly, to do that with an alias list,
[speechRecognitionInstance addAlias:@"PEOPLE" forItems:[NSArray arrayWithObjects:@"joe", @"charlie", @"ben", nil]];
[speechRecognitionInstance addCommand:@"call %PEOPLE%"];
Declared In
ISSpeechRecognition.haddCommand:
Adds a command.
- (void)addCommand:(NSString *)commandParameters
- command
The command to be added.
Discussion
If you want to reference an alias list, the format is %ALIAS_LIST_NAME%. Replace ALIAS_LIST_NAME with the actual name of your alias list.
Declared In
ISSpeechRecognition.haddCommands:
Add multiple commands from an array.
- (void)addCommands:(NSArray *)commandsParameters
- commands
The array of commands to be added.
Declared In
ISSpeechRecognition.hcancel
Cancels an in progress speech recognition action.
- (void)cancelDiscussion
If, for some reason, you need to cancel an in progress speech recognition action, call this method. It’s also a good idea to provide feedback to the user as to why you cancelled it.
Declared In
ISSpeechRecognition.hfinishListenAndStartRecognize
If you’re running an untimed listen, or if you want to cut a timed listen short, call this method to tell the SDK to stop listening for audio, and finish up transcribing.
- (void)finishListenAndStartRecognizeDeclared In
ISSpeechRecognition.hlisten:
Start an untimed listen.
- (BOOL)listen:(NSError **)errParameters
- err
An
NSErrorpointer to get an error object out of the method if something goes wrong.
Return Value
Returns whatever speech synthesis successfully started. If this returns NO, check the error for details on what went wrong.
Discussion
An untimed listen means that the SDK will start listening, and will not stop unless you tell it to by calling –[ISSpeechRecognition finishListenAndStartRecognize], or until silence detection kicks in, if you have that enabled.
If you’re using a command or alias list, use -listenAndRecognizeWithTimeout:error: instead. This will ensure that speech recognition will only last as long as is necessary, thus saving the user’s battery life and data plan, ensuring that you get a result back, and providing an better overall experience.
Declared In
ISSpeechRecognition.hlistenAndRecognizeWithTimeout:error:
Starts a timed listen. After a set timeout, the SDK will stop listening for audio and will start to transcribe it.
- (BOOL)listenAndRecognizeWithTimeout:(NSTimeInterval)timeout error:(NSError **)errParameters
- timeout
The amount of time, in seconds, for the timed listen to last for.
- err
An
NSErrorpointer to get an error object out of the method if something goes wrong.
Return Value
Returns whatever speech synthesis successfully started. If this returns NO, check the error for details on what went wrong.
Discussion
Useful when using command lists to ensure that the user doesn’t talk longer than necessary.
Declared In
ISSpeechRecognition.hlistenAndRecognizeWithTimeout:handler:
Starts a timed listen. After a set timeout, the SDK will stop listening for audio and will start to transcribe it.
- (void)listenAndRecognizeWithTimeout:(NSTimeInterval)timeout handler:(ISSpeechRecognitionHandler)handlerParameters
- timeout
The amount of time, in seconds, for the timed listen to last for.
- handler
An
ISSpeechRecognitionHandlerblock that will be executed on the main thread when speech recognition completes, or when an error occurs.
Discussion
Useful when using command lists to ensure that the user doesn’t talk longer than necessary.
Declared In
ISSpeechRecognition.hlistenWithHandler:
Start an untimed listen.
- (void)listenWithHandler:(ISSpeechRecognitionHandler)handlerParameters
- handler
An
ISSpeechRecognitionHandlerblock that will be executed on the main thread when speech recognition completes, or when an error occurs.
Discussion
An untimed listen means that the SDK will start listening, and will not stop unless you tell it to by calling –[ISSpeechRecognition finishListenAndStartRecognize], or until silence detection kicks in, if you have that enabled.
If you’re using a command or alias list, use -listenAndRecognizeWithTimeout:handler: instead. This will ensure that speech recognition will only last as long as is necessary, thus saving the user’s battery life and data plan, ensuring that you get a result back, and providing an better overall experience.
Declared In
ISSpeechRecognition.h