Contents

SNClassifySoundRequest

A request that classifies sound using a Core ML model.

Declaration

class SNClassifySoundRequest

Mentioned in

Overview

An SNClassifySoundRequest represents a specific sound classification model. Analyze audio data with a sound classification model by:

  1. Creating an SNClassifySoundRequest, either with the Sound Analysis model, or by providing your custom Core ML model.

  2. Adding the sound request to an SNAudioFileAnalyzer or SNAudioStreamAnalyzer to process an audio file or stream, respectively.

func makeRequest(_ customModel: MLModel? = nil) throws -> SNClassifySoundRequest {
    // If applicable, create a request with a custom sound classification model.
    if let model = customModel {
        let customRequest = try SNClassifySoundRequest(mlModel: model)
        return customRequest
    }

    // Create a request with the Sound Analysis model.
    let version1 = SNClassifierIdentifier.version1
    let request = try SNClassifySoundRequest(classifierIdentifier: version1)

    return request
}

let classifySoundRequest = try makeRequest()

// Prints every label in the request's sound classification model.
print(classifySoundRequest.knownClassifications)

For more information about creating and using classify sound requests, see:

Topics

Creating a Request

Configuring a Request

Inspecting a Request

Instance Properties

Initializers

See Also

Sound classification requests