---
title: "recognitionTask(with:delegate:)"
framework: speech
role: symbol
role_heading: Instance Method
path: "speech/sfspeechrecognizer/recognitiontask(with:delegate:)"
---

# recognitionTask(with:delegate:)

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

## Declaration

```swift
func recognitionTask(with request: SFSpeechRecognitionRequest, delegate: any SFSpeechRecognitionTaskDelegate) -> SFSpeechRecognitionTask
```

## Parameters

- `request`: A request (encapsulated in an doc://com.apple.speech/documentation/Speech/SFSpeechRecognitionRequest object) to recognize speech from an audio source.
- `delegate`: An object that can handle results from the speech recognition task. This object must conform to the doc://com.apple.speech/documentation/Speech/SFSpeechRecognitionTaskDelegate protocol.

## Return Value

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

## Discussion

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 methods of the provided delegate object. Note that the SFSpeechRecognitionTask object returned by this method does not retain your delegate object. You must maintain a strong reference to your delegate while speech recognition is in progress.

## See Also

### Performing speech recognition on audio

- [recognitionTask(with:resultHandler:)](speech/sfspeechrecognizer/recognitiontask(with:resulthandler:).md)
- [SFSpeechRecognitionTaskDelegate](speech/sfspeechrecognitiontaskdelegate.md)
