MediaPipe Tasks' audio container.
mp
.
tasks
.
components
.
containers
.
AudioData
(
buffer_length
:
int
,
audio_format
:
mp
.
tasks
.
components
.
containers
.
AudioDataFormat
=
AudioDataFormat
()
)
->
None
Methods
clear
clear
()
Clears the internal buffer and fill it with zeros.
create_from_array
@classmethodcreate_from_array ( src : np . ndarray , sample_rate : Optional [ float ] = None ) -> 'AudioData'
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
load_from_array
(
src
:
np
.
ndarray
,
offset
:
int
=
0
,
size
:
int
=
-
1
)
->
None
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.

