[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-01 UTC."],[],[],null,["# mp.tasks.components.containers.AudioData\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/google/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L34-L137) |\n\nMediaPipe Tasks' audio container. \n\n mp.tasks.components.containers.AudioData(\n buffer_length: int,\n audio_format: ../../../../mp/tasks/components/containers/AudioDataFormat = ../../../../mp/tasks/components/containers/AudioDataFormat\n ) -\u003e None\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|---------------------------------|\n| `buffer_length` | the length of the audio buffer. |\n| `audio_format` | the audio format metadata. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------|-------------------------------------|\n| `audio_format` | Gets the audio format of the audio. |\n| `buffer` | Gets the internal buffer. |\n| `buffer_length` | Gets the sample count of the audio. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `clear`\n\n[View source](https://github.com/google/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L52-L54) \n\n clear()\n\nClears the internal buffer and fill it with zeros.\n\n### `create_from_array`\n\n[View source](https://github.com/google/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L102-L122) \n\n @classmethod\n create_from_array(\n src: np.ndarray, sample_rate: Optional[float] = None\n ) -\u003e 'AudioData'\n\nCreates an `AudioData` object from a NumPy array.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------------|------------------------------------------------|\n| `src` | A NumPy source array contains the input audio. |\n| `sample_rate` | the optional audio sample rate. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| An `AudioData` object that contains a copy of the NumPy source array as the data. ||\n\n\u003cbr /\u003e\n\n### `load_from_array`\n\n[View source](https://github.com/google/mediapipe/blob/master/mediapipe/tasks/python/components/containers/audio_data.py#L56-L100) \n\n load_from_array(\n src: np.ndarray, offset: int = 0, size: int = -1\n ) -\u003e None\n\nLoads the audio data from a NumPy array.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|-----------------------------------------------------------------------------------------|\n| `src` | A NumPy source array contains the input audio. |\n| `offset` | An optional offset for loading a slice of the `src` array to the buffer. |\n| `size` | An optional size parameter denoting the number of samples to load from the `src` array. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|--------------|----------------------------------------------------------------------------------------------------------|\n| `ValueError` | If the input array has an incorrect shape or if `offset` + `size` exceeds the length of the `src` array. |\n\n\u003cbr /\u003e"]]