<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 10.0.0 -",
    "macOS: 10.15.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Speech",
  "identifier" : "/documentation/Speech/SFSpeechRecognizer/recognitionTask(with:resultHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Speech"
    ],
    "preciseIdentifier" : "c:objc(cs)SFSpeechRecognizer(im)recognitionTaskWithRequest:resultHandler:"
  },
  "title" : "recognitionTask(with:resultHandler:)"
}
-->

# recognitionTask(with:resultHandler:)

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

```
func recognitionTask(with request: SFSpeechRecognitionRequest, resultHandler: @escaping (SFSpeechRecognitionResult?, (any Error)?) -> Void) -> SFSpeechRecognitionTask
```

## Parameters

`request`

A request (in an [`SFSpeechRecognitionRequest`](/documentation/Speech/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`](/documentation/Speech/SFSpeechRecognitionRequest/shouldReportPartialResults) property is `true`, 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`](/documentation/Speech/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`](/documentation/Speech/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)