MediaPipeTasksAudio Framework Reference

AudioClassifierOptions

class AudioClassifierOptions: TaskOptions, NSCopying

Options for setting up a AudioClassifier.

  • An object that confirms to AudioClassifierStreamDelegate protocol. This object must implement objectDetector(_:didFinishDetectionWithResult:timestampInMilliseconds:error:) to receive the results of asynchronous classification on audio stream (i.e, when runningMode = .audioStream).

    Declaration

    Swift

    weak var audioClassifierStreamDelegate: (any AudioClassifierStreamDelegate)? { get set }
  • The allowlist of category names. If non-empty, detection results whose category name is not in this set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryDenylist.

    Declaration

    Swift

    var categoryAllowlist: [String] { get set }
  • The denylist of category names. If non-empty, detection results whose category name is in this set will be filtered out. Duplicate or unknown category names are ignored. Mutually exclusive with categoryAllowlist.

    Declaration

    Swift

    var categoryDenylist: [String] { get set }
  • The locale to use for display names specified through the TFLite Model Metadata, if any. Defaults to English.

    Declaration

    Swift

    var displayNamesLocale: String { get set }
  • The maximum number of top-scored classification results to return. If < 0, all available results will be returned. If 0, an invalid argument error is returned.

    Declaration

    Swift

    var maxResults: Int { get set }
  • Running mode of the audio classifier task. Defaults to .image. AudioClassifier can be created with one of the following running modes: 1. .audioClips: The mode for performing classification on independent audio clips. 2. .audioStream: The mode for performing classification on an audio stream, such as from a microphone.

    Declaration

    Swift

    var runningMode: RunningMode { get set }
  • Score threshold to override the one provided in the model metadata (if any). Results below this value are rejected.

    Declaration

    Swift

    var scoreThreshold: CFloat { get set }