Instance Method

recognitionTaskWithRequest:resultHandler:

Executes the speech recognition request and delivers the results to the specified handler block.

Declaration

- (SFSpeechRecognitionTask *)recognitionTaskWithRequest:(SFSpeechRecognitionRequest *)request resultHandler:(void (^)(SFSpeechRecognitionResult *result, NSError *error))resultHandler;

Parameters

request

A request (in an SFSpeechRecognitionRequest object) to recognize speech from an audio source.

resultHandler

The block to call when partial or final results are available, or when an error occurs. If the shouldReportPartialResults property is YES, this block may be called multiple times to deliver the partial and final results. The block has no return value and takes the following parameters:

result

A SFSpeechRecognitionResult containing the partial or final transcriptions of the audio content.

error

An error object if a problem occurred. This parameter is nil if speech recognition was successful.

Return Value

The task object you can use to manage an in-progress recognition request.

Discussion

Use this method to initiate the speech recognition process on the audio contained in the request object. This method executes asynchronously and returns a SFSpeechRecognitionTask object that you can use to cancel or finalize the recognition process later. As results become available, the method calls the block in the resultHandler parameter.

See Also

Performing Speech Recognition on Audio

- recognitionTaskWithRequest:delegate:

Recognizes speech from the audio source associated with the specified request, using the specified delegate to manage the results.

SFSpeechRecognitionTaskDelegate

A protocol with methods for managing multi-utterance speech recognition requests.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software