mp.tasks.components.containers.AudioData

MediaPipe Tasks' audio container.

buffer_length the length of the audio buffer.
audio_format the audio format metadata.

audio_format Gets the audio format of the audio.
buffer Gets the internal buffer.
buffer_length Gets the sample count of the audio.

Methods

clear

View source

Clears the internal buffer and fill it with zeros.

create_from_array

View source

Creates an AudioData object from a NumPy array.

Args
src A NumPy source array contains the input audio.
sample_rate the optional audio sample rate.

Returns
An AudioData object that contains a copy of the NumPy source array as the data.

load_from_array

View source

Loads the audio data from a NumPy array.

Args
src A NumPy source array contains the input audio.
offset An optional offset for loading a slice of the src array to the buffer.
size An optional size parameter denoting the number of samples to load from the src array.

Raises
ValueError If the input array has an incorrect shape or if offset + size exceeds the length of the src array.