AudioEmbedder class

Performs embedding extraction on audio.

Signature:

  export 
  
 declare 
  
 class 
  
 AudioEmbedder 
  
 extends 
  
 AudioTaskRunner<AudioEmbedderResult 
 [] 
>  
 

Extends: AudioTaskRunner< AudioEmbedderResult []>

Methods

Method Modifiers Description
static Initializes the Wasm runtime and creates a new audio embedder based on the provided model asset buffer.
static Initializes the Wasm runtime and creates a new audio embedder based on the path to the model asset.
static Initializes the Wasm runtime and creates a new audio embedder from the provided options.
Performs embeding extraction on the provided audio clip and waits synchronously for the response.
Sets new options for the audio embedder.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 .

AudioEmbedder.createFromModelBuffer()

Initializes the Wasm runtime and creates a new audio embedder based on the provided model asset buffer.

Signature:

  static 
  
 createFromModelBuffer 
 ( 
 wasmFileset 
 : 
  
 WasmFileset 
 , 
  
 modelAssetBuffer 
 : 
  
 Uint8Array 
 ) 
 : 
  
 Promise<AudioEmbedder> 
 ; 
 

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 TFLite model.

Returns:

Promise< AudioEmbedder >

AudioEmbedder.createFromModelPath()

Initializes the Wasm runtime and creates a new audio embedder based on the path to the model asset.

Signature:

  static 
  
 createFromModelPath 
 ( 
 wasmFileset 
 : 
  
 WasmFileset 
 , 
  
 modelAssetPath 
 : 
  
 string 
 ) 
 : 
  
 Promise<AudioEmbedder> 
 ; 
 

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 TFLite model.

Returns:

Promise< AudioEmbedder >

AudioEmbedder.createFromOptions()

Initializes the Wasm runtime and creates a new audio embedder from the provided options.

Signature:

  static 
  
 createFromOptions 
 ( 
 wasmFileset 
 : 
  
 WasmFileset 
 , 
  
 audioEmbedderOptions 
 : 
  
 AudioEmbedderOptions 
 ) 
 : 
  
 Promise<AudioEmbedder> 
 ; 
 

Parameters

Parameter Type Description
wasmFileset
WasmFileset A configuration object that provides the location of the Wasm binary and its loader.
audioEmbedderOptions
AudioEmbedderOptions The options for the audio embedder. Note that either a path to the TFLite model or the model itself needs to be provided (via baseOptions ).

Returns:

Promise< AudioEmbedder >

AudioEmbedder.embed()

Performs embeding extraction on the provided audio clip and waits synchronously for the response.

Signature:

  embed 
 ( 
 audioData 
 : 
  
 Float32Array 
 , 
  
 sampleRate? 
 : 
  
 number 
 ) 
 : 
  
 AudioEmbedderResult 
 []; 
 

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 embedding resuls of the audio

Returns:

AudioEmbedderResult []

AudioEmbedder.setOptions()

Sets new options for the audio embedder.

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 
 : 
  
 AudioEmbedderOptions 
 ) 
 : 
  
 Promise<void> 
 ; 
 

Parameters

Parameter Type Description
options
AudioEmbedderOptions The options for the audio embedder.

Returns:

Promise<void>

Design a Mobile Site
View Site in Mobile | Classic
Share by: