[[["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-08 UTC."],[],[],null,["# tflite_support.task.audio.AudioRecord\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/core/audio_record.py#L30-L126) |\n\nA class to record audio in a streaming basis. \n\n tflite_support.task.audio.AudioRecord(\n channels: int, sampling_rate: int, buffer_size: int\n ) -\u003e None\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|-----------------------------------------------|\n| `channels` | Number of input channels. |\n| `sampling_rate` | Sampling rate in Hertz. |\n| `buffer_size` | Size of the ring buffer in number of samples. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|---------------|------------------------------------------|\n| `ValueError` | if any of the arguments is non-positive. |\n| `ImportError` | if failed to import `sounddevice`. |\n| `OSError` | if failed to load `PortAudio`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------|---------------|\n| `buffer_size` | \u003cbr /\u003e \u003cbr /\u003e |\n| `channels` | \u003cbr /\u003e \u003cbr /\u003e |\n| `sampling_rate` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `read`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/core/audio_record.py#L108-L126) \n\n read(\n size: int\n ) -\u003e np.ndarray\n\nReads the latest audio data captured in the buffer.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|--------|--------------------------------------------|\n| `size` | Number of samples to read from the buffer. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| A NumPy array containing the audio data. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|--------------|--------------------------------------------------|\n| `ValueError` | Raised if `size` is larger than the buffer size. |\n\n\u003cbr /\u003e\n\n### `start_recording`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/core/audio_record.py#L96-L102) \n\n start_recording() -\u003e None\n\nStarts the audio recording.\n\n### `stop`\n\n[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/audio/core/audio_record.py#L104-L106) \n\n stop() -\u003e None\n\nStops the audio recording."]]