Performs audio classification.
Signature:
export declare class AudioClassifier extends AudioTaskRunner<AudioClassifierResult[]>
Extends: AudioTaskRunner<AudioClassifierResult[]>
Methods
| Method | Modifiers | Description |
|---|---|---|
| classify(audioData, sampleRate) | Performs audio classification on the provided audio clip and waits synchronously for the response. | |
| createFromModelBuffer(wasmFileset, modelAssetBuffer) | static |
Initializes the Wasm runtime and creates a new audio classifier based on the provided model asset buffer. |
| createFromModelPath(wasmFileset, modelAssetPath) | static |
Initializes the Wasm runtime and creates a new audio classifier based on the path to the model asset. |
| createFromOptions(wasmFileset, audioClassifierOptions) | static |
Initializes the Wasm runtime and creates a new audio classifier from the provided options. |
| setOptions(options) | Sets new options for the audio classifier.Calling setOptions() with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to undefined. |
AudioClassifier.classify()
Performs audio classification on the provided audio clip and waits synchronously for the response.
Signature:
classify(audioData: Float32Array, sampleRate?: number): AudioClassifierResult[];
Parameters
| Parameter | Type | Description |
|---|---|---|
| audioData | Float32Array | An array of raw audio capture data, like from a call to getChannelData() on an AudioBuffer. |
| sampleRate | number | The sample rate in Hz of the provided audio data. If not set, defaults to the sample rate set via setDefaultSampleRate() or 48000 if no custom default was set. The classification result of the audio data |
Returns:
AudioClassifier.createFromModelBuffer()
Initializes the Wasm runtime and creates a new audio classifier based on the provided model asset buffer.
Signature:
static createFromModelBuffer(wasmFileset: WasmFileset, modelAssetBuffer: Uint8Array): Promise<AudioClassifier>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetBuffer | Uint8Array | A binary representation of the model. |
Returns:
Promise<AudioClassifier>
AudioClassifier.createFromModelPath()
Initializes the Wasm runtime and creates a new audio classifier based on the path to the model asset.
Signature:
static createFromModelPath(wasmFileset: WasmFileset, modelAssetPath: string): Promise<AudioClassifier>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| modelAssetPath | string | The path to the model asset. |
Returns:
Promise<AudioClassifier>
AudioClassifier.createFromOptions()
Initializes the Wasm runtime and creates a new audio classifier from the provided options.
Signature:
static createFromOptions(wasmFileset: WasmFileset, audioClassifierOptions: AudioClassifierOptions): Promise<AudioClassifier>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| wasmFileset | WasmFileset | A configuration object that provides the location of the Wasm binary and its loader. |
| audioClassifierOptions | AudioClassifierOptions | The options for the audio classifier. Note that either a path to the model asset or a model buffer needs to be provided (via baseOptions). |
Returns:
Promise<AudioClassifier>
AudioClassifier.setOptions()
Sets new options for the audio classifier.
Calling setOptions() with a subset of options only affects those options. You can reset an option back to its default value by explicitly setting it to undefined.
Signature:
setOptions(options: AudioClassifierOptions): Promise<void>;
Parameters
| Parameter | Type | Description |
|---|---|---|
| options | AudioClassifierOptions | The options for the audio classifier. |
Returns:
Promise<void>