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.

    error

    An optional error parameter populated when there is an error in initializing the audio transcriber.

    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.

    error

    An optional error parameter populated when there is an error in initializing the audio transcriber.

    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

    Parameters

    error

    An optional error parameter populated when closing fails.

    Return Value

    YES if the MPPAudioTranscriber was successfully closed, NO otherwise.

  • Flushes any remaining buffered audio and finalizes the current stream.

    Declaration

    Swift

    func finishStream() throws -> AudioTranscriberResult

    Parameters

    error

    An optional error parameter populated when there is an error finalizing the stream.

    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

    Parameters

    error

    An optional error parameter populated when prewarming fails.

    Return Value

    YES if prewarming succeeded, NO otherwise.

  • 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 -> 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.

    error

    An optional error parameter populated when there is an error during transcription.

    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.

    error

    An optional error parameter populated when there is an error during transcription.

    Return Value

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