<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L38-L152) |

MediaPipe Tasks' audio container.

    mp.tasks.components.containers.AudioData(
        buffer_length: int,
        audio_format: https://developers.google.com/edge/api/mediapipe/python/mp/tasks/components/containers/AudioDataFormat = https://developers.google.com/edge/api/mediapipe/python/mp/tasks/components/containers/AudioDataFormat
    ) -> None

<br />

<br />

<br />

| ## Args ||
|---|---|
| `buffer_length` | the length of the audio buffer. |
| `audio_format` | the audio format metadata. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `audio_format` | Gets the audio format of the audio. |
| `buffer` | Gets the internal buffer. |
| `buffer_length` | Gets the sample count of the audio. |

<br />

## Methods

### `clear`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L56-L58)

    clear()

Clears the internal buffer and fill it with zeros.

### `create_from_array`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L106-L127)

    @classmethod
    create_from_array(
        src: np.ndarray, sample_rate: Optional[float] = None
    ) -> 'AudioData'

Creates an `AudioData` object from a NumPy array.

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

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

<br />

### `load_from_array`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L60-L104)

    load_from_array(
        src: np.ndarray, offset: int = 0, size: int = -1
    ) -> None

Loads the audio data from a NumPy array.

<br />

<br />

<br />

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

<br />

<br />

<br />

<br />

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

<br />

### `to_ctypes`

[View source](https://github.com/google-ai-edge/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L144-L152)

    to_ctypes() -> audio_data_c.MpAudioDataC

Converts the object to a ctypes audio data object.