ISSpeechRecognition Class Reference
Inherits from | NSObject |
Declared in | ISSpeechRecognition.h |
Tasks
Getting and Setting the Delegate
-
delegate
The delegate of a speech recognition object.
property
Configuration Properties
-
locale
Sets the locale to use for speech recognition.
property -
model
Allows you to set a custom language model for speech recognition.
property -
freeformType
The type of model to use when trascribing audio. Defaults to
propertyISFreeFormTypeDictation
. -
silenceDetectionEnabled
Whether silence detection should be used to automatically detect when someone’s done talking.
property
Detecting Audio Input
-
+ 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.
Aliases and Commands
-
– addAlias:forItems:
Adds a list of items as an alias.
-
– addCommand:
Adds a command.
-
– addCommands:
Add multiple commands from an array.
-
– resetCommandsAndAliases
Clears any command or alias lists on this speech recognition object.
Listening and Recognizing
-
– listen:
Start an untimed listen.
-
– finishListenAndStartRecognize
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.
-
– 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.
-
– cancel
Cancels an in progress speech recognition action.
Properties
delegate
The delegate of a speech recognition object.
@property (nonatomic, unsafe_unretained) id<ISSpeechRecognitionDelegate> delegate
Discussion
The delegate must adopt the ISSpeechRecognitionDelegate
protocol.
Declared In
ISSpeechRecognition.h
freeformType
The type of model to use when trascribing audio. Defaults to ISFreeFormTypeDictation
.
@property (nonatomic, assign) ISFreeFormType freeformType
Declared In
ISSpeechRecognition.h
locale
Sets the locale to use for speech recognition.
@property (nonatomic, copy) NSString *locale
Discussion
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.h
Class 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)audioInputAvailable
Return Value
Returns whether audio input is available.
Declared In
ISSpeechRecognition.h
Instance Methods
addAlias:forItems:
Adds a list of items as an alias.
- (void)addAlias:(NSString *)alias forItems:(NSArray *)items
Parameters
- 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.h
addCommand:
Adds a command.
- (void)addCommand:(NSString *)command
Parameters
- 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.h
addCommands:
Add multiple commands from an array.
- (void)addCommands:(NSArray *)commands
Parameters
- commands
The array of commands to be added.
Declared In
ISSpeechRecognition.h
cancel
Cancels an in progress speech recognition action.
- (void)cancel
Discussion
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.h
finishListenAndStartRecognize
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)finishListenAndStartRecognize
Declared In
ISSpeechRecognition.h
listen:
Start an untimed listen.
- (BOOL)listen:(NSError **)err
Parameters
- err
An
NSError
pointer 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.h
listenAndRecognizeWithTimeout: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 **)err
Parameters
- timeout
The amount of time, in seconds, for the timed listen to last for.
- err
An
NSError
pointer 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.h
listenAndRecognizeWithTimeout: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)handler
Parameters
- timeout
The amount of time, in seconds, for the timed listen to last for.
- handler
An
ISSpeechRecognitionHandler
block 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.h
listenWithHandler:
Start an untimed listen.
- (void)listenWithHandler:(ISSpeechRecognitionHandler)handler
Parameters
- handler
An
ISSpeechRecognitionHandler
block 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