AudioTranscriber
class AudioTranscriber: NSObjectPerforms automatic speech recognition (ASR) on streaming mono PCM float audio samples.
-
Creates a new instance of
MPPAudioTranscriberfrom an absolute path to a model asset bundle stored locally on the device and the defaultMPPAudioTranscriberOptions.Declaration
Swift
convenience init(modelPath: String) throwsParameters
modelPathAn absolute path to a model file stored locally on the device.
errorAn optional error parameter populated when there is an error in initializing the audio transcriber.
Return Value
A new instance of
MPPAudioTranscriberwith the given model path.nilif there is an error in initializing the audio transcriber. -
Creates a new instance of
MPPAudioTranscriberfrom the givenMPPAudioTranscriberOptions.Declaration
Swift
init(options: AudioTranscriberOptions) throwsParameters
optionsThe options of type
MPPAudioTranscriberOptionsto use for configuring theMPPAudioTranscriber.errorAn optional error parameter populated when there is an error in initializing the audio transcriber.
Return Value
A new instance of
MPPAudioTranscriberwith the given options.nilif there is an error in initializing the audio transcriber. -
Releases underlying inference engine and processor resources.
Declaration
Swift
func close() throwsParameters
errorAn optional error parameter populated when closing fails.
Return Value
YESif theMPPAudioTranscriberwas successfully closed,NOotherwise. -
Flushes any remaining buffered audio and finalizes the current stream.
Declaration
Swift
func finishStream() throws -> AudioTranscriberResultParameters
errorAn optional error parameter populated when there is an error finalizing the stream.
Return Value
An
MPPAudioTranscriberResultcontaining any final emitted segments, ornilon error. -
Prewarms the underlying inference engine to reduce first-chunk latency.
Declaration
Swift
func prewarm() throwsParameters
errorAn optional error parameter populated when prewarming fails.
Return Value
YESif prewarming succeeded,NOotherwise. -
Transcribes a contiguous buffer of mono PCM float audio samples in
[-1.0, 1.0].Declaration
Swift
func transcribe(samples: UnsafePointer<CFloat>?, count length: UInt, endOfStream: Bool) throws -> AudioTranscriberResultParameters
samplesPointer to a contiguous array of mono PCM float audio samples.
lengthNumber of float samples in
samples.endOfStreamWhether this chunk marks the end of the audio stream.
errorAn optional error parameter populated when there is an error during transcription.
Return Value
An
MPPAudioTranscriberResultcontaining any emitted segments, ornilon error. -
Transcribes an array of mono PCM float audio samples in
[-1.0, 1.0].Declaration
Swift
func transcribe(samples: [NSNumber], endOfStream: Bool) throws -> AudioTranscriberResultParameters
samplesArray of
NSNumberfloat values representing mono PCM audio samples.endOfStreamWhether this chunk marks the end of the audio stream.
errorAn optional error parameter populated when there is an error during transcription.
Return Value
An
MPPAudioTranscriberResultcontaining any emitted segments, ornilon error.