A wrapper class to store the input audio.

audio_format format of the audio.
buffer_size buffer size of the audio.

buffer Gets the internal buffer.
buffer_size Gets the sample count of the audio.
format Gets the audio format of the audio.



View source

Clear the internal buffer and fill it with zeros.


View source

Creates TensorAudio object from the WAV file.

file_name WAV file name.
sample_count The number of samples to read from the WAV file. This value should match with the input size of the TensorFlow Lite audio model that will consume the created TensorAudio object. If the WAV file contains more samples than sample_count, only the samples at the beginning of the WAV file will be loaded.
offset An optional offset for allowing the user to skip a certain number samples at the beginning.

TensorAudio object.

ValueError If an input parameter, such as the audio file, is invalid.
RuntimeError If other types of error occurred.


View source

Loads the audio data from a NumPy array.

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.

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


View source

Loads audio data from an AudioRecord instance.

record An AudioRecord instance.

ValueError Raised if the audio record's config is invalid.
RuntimeError Raised if other types of error occurred.