recognizeDeviceAudio
Starts asynchronous speech recognition on live device audio.
Declaration
public func recognizeDeviceAudio(
_ mediaJobID: String,
srTaskID: String,
srParams: STSRParams? = nil,
audioRecordParams: STAudioRecordParams? = nil,
recordUtteranceAudio: Bool = false
) -> STResultOverview
Recognizes speech from live microphone input asynchronously. Initialize the required media components and obtain microphone and speech-recognition permissions. Because this operation captures device audio, the iOS background-recording restriction also applies: start recognition while foregrounded; supported ongoing capture may continue in the background with the required audio configuration.
iOS Background Recording
On iOS, enabling background audio does not permit starting a new microphone recording while the application is already in the background. Begin microphone recording while the application is in the foreground. An existing recording may continue after the application enters the background when the audio session and background mode are configured appropriately. Live speech recognition uses microphone recording, so the same restriction applies to recognizeDeviceAudio.
Parameters
mediaJobID identifies the overall media operation and is returned with related events.
srTaskID identifies the recognition task.
srParams optionally controls the recognition task, partial results, punctuation, contextual phrases, continuous recognition, and on-device recognition requirement.
audioRecordParams optionally controls the audio-capture side of recognition.
recordUtteranceAudio requests storage of the recognition audio as utterance audio.
Return value and events
Returns .success when the request is accepted; recognition then proceeds asynchronously. Initialization, permission, engine, language, or recognition errors are represented by other STResult values.
Partial hypotheses, hypotheses, and completion are reported through typed media events.