iOS Guides | Samples

Speech Namespace

The Speech namespace provides access to speech-recognition services.


The Speech namespace, added in iOS 10, provides developers the ability to use speech recognition in their apps above-and-beyond the system-provided keyboard dictation or SiriKit.

Speech recognition is performed by a SFSpeechRecognizer object. A speech request is encapsulated in an SFSpeechRecognitionRequest and an SFSpeechRecognitionTask.

The SFSpeechRecognizer asynchronously processes the SFSpeechRecognitionTask and calls a handler delegate (possibly several times). The result contains the best and alternate matches, as shown in the following example:

C# Example

var result = speechRecognizer.GetRecognitionTask(recognitionRequest, (recoResult, recoErr) =>
			if (recoErr != null) { // ... etc ... }
				if (recoResult.BestTranscription != null)
					textView.Text = recoResult.BestTranscription.FormattedString;

The SFSpeechRecognitionRequest is an abstract base class for SFSpeechAudioBufferRecognitionRequest, which is used with hardware devices and SFSpeechUrlRecognitionRequest, which transcribes audio already stored in a URL-available resource. Developers who use SFSpeechAudioBufferRecognitionRequest objects must add the following keys, with appropriate descriptions, to their applications' info.plist file:

XML Example

	<string>Your microphone will be used to record your speech when you press the "Start Recording" button.</string>
	<string>Speech recognition will be used to determine which words you speak into this device's microphone.</string>

If an application does not have these keys, the operating system will execute a "silent" shutdown at runtime, with no exception or ability to log the mistake.

Speech recognition requires Internet access.


ISFSpeechRecognitionTaskDelegateInterface representing the required methods (if any) of the protocol SFSpeechRecognitionTaskDelegate.
ISFSpeechRecognizerDelegateInterface representing the required methods (if any) of the protocol SFSpeechRecognizerDelegate.
SFSpeechAudioBufferRecognitionRequestAn SFSpeechRecognitionRequest that takes its input from an audio buffer.
SFSpeechRecognitionRequestAbstract base class for speech recognition requests (see SFSpeechAudioBufferRecognitionRequest and SFSpeechUrlRecognitionRequest).
SFSpeechRecognitionResultContains transcriptions of a speech recognition task.
SFSpeechRecognitionTaskObject that holds state and provides control of an asynchronous speech recognition task.
SFSpeechRecognitionTaskDelegateDelegate object whose members are called in reaction to speech-recognition events.
SFSpeechRecognitionTaskDelegate_ExtensionsExtension methods to the ISFSpeechRecognitionTaskDelegate interface to support all the methods from the SFSpeechRecognitionTaskDelegate protocol.
SFSpeechRecognitionTaskStateEnumerates the states of a SFSpeechRecognitionTask.
SFSpeechRecognizerEncapsulates the speech recognition facilities.
SFSpeechRecognizerAuthorizationStatusEnumeration of the permission status of speech recognition.
SFSpeechRecognizerDelegateDelegate object for SFSpeechRecognizer.
SFSpeechRecognizerDelegate_ExtensionsExtension methods to the ISFSpeechRecognizerDelegate interface to support all the methods from the SFSpeechRecognizerDelegate protocol.
SFSpeechUrlRecognitionRequestA SFSpeechRecognitionRequest whose audio source is specified in a URL
SFTranscriptionA conversion of speech into text.