MediaPipeTasksAudio Framework Reference

AudioTranscriber

class AudioTranscriber: NSObject

Performs automatic speech recognition (ASR) on streaming mono PCM float audio samples.

  • Creates a new instance of MPPAudioTranscriber from an absolute path to a model asset bundle stored locally on the device and the default MPPAudioTranscriberOptions.

    Declaration

    Swift

    convenience init(modelPath: String) throws

    Parameters

    modelPath

    An absolute path to a model file stored locally on the device.

    Return Value

    A new instance of MPPAudioTranscriber with the given model path. nil if there is an error in initializing the audio transcriber.

  • Creates a new instance of MPPAudioTranscriber from the given MPPAudioTranscriberOptions.

    Declaration

    Swift

    init(options: AudioTranscriberOptions) throws

    Parameters

    options

    The options of type MPPAudioTranscriberOptions to use for configuring the MPPAudioTranscriber.

    Return Value

    A new instance of MPPAudioTranscriber with the given options. nil if there is an error in initializing the audio transcriber.

  • Releases underlying inference engine and processor resources.

    Declaration

    Swift

    func close() throws
  • Flushes any remaining buffered audio and finalizes the current stream.

    Declaration

    Swift

    func finishStream() throws -> AudioTranscriberResult

    Return Value

    An MPPAudioTranscriberResult containing any final emitted segments, or nil on error.

  • Prewarms the underlying inference engine to reduce first-chunk latency.

    Declaration

    Swift

    func prewarm() throws
  • Transcribes a contiguous buffer of mono PCM float audio samples in [-1.0, 1.0].

    Declaration

    Swift

    func transcribe(samples: UnsafePointer<Float>?, count length: UInt, endOfStream: Bool) throws -> AudioTranscriberResult

    Parameters

    samples

    Pointer to a contiguous array of mono PCM float audio samples.

    length

    Number of float samples in samples.

    endOfStream

    Whether this chunk marks the end of the audio stream.

    Return Value

    An MPPAudioTranscriberResult containing any emitted segments, or nil on error.

  • Transcribes an array of mono PCM float audio samples in [-1.0, 1.0].

    Declaration

    Swift

    func transcribe(samples: [NSNumber], endOfStream: Bool) throws -> AudioTranscriberResult

    Parameters

    samples

    Array of NSNumber float values representing mono PCM audio samples.

    endOfStream

    Whether this chunk marks the end of the audio stream.

    Return Value

    An MPPAudioTranscriberResult containing any emitted segments, or nil on error.