athena.transform.feats.read_wav
¶
The model reads audio sample from wav file.
Module Contents¶
Classes¶
Read audio sample from wav file, return sample data and sample rate. The operation |
Functions¶
|
Read wav from file. Can be called directly without ReadWav class. |
- class athena.transform.feats.read_wav.ReadWav(config: dict)¶
Bases:
athena.transform.feats.base_frontend.BaseFrontend
Read audio sample from wav file, return sample data and sample rate. The operation is based on tensorflow.audio.decode_wav.
- Parameters
config – a dictionary contains optional parameters of read wav.
Examples
>>> config = {'audio_channels': 1} >>> read_wav_op = ReadWav.params(config).instantiate() >>> audio_data, sample_rate = read_wav_op('test.wav')
Note: The range of audio data are -32768 to 32767 (for 16 bits), not -1 to 1.
- classmethod params(config=None)¶
Set params.
- Parameters
config – contains the following two optional parameters
'type' – ‘ReadWav’.
'audio_channels' – index of the desired channel. (default=1)
Note
Return an object of class HParams, which is a set of hyperparameters as name-value pairs.
- call(wavfile, speed=1.0)¶
Get audio data and sample rate from a wavfile.
- Parameters
wavfile – filepath of wav.
speed – Speed of sample channels wanted. (default=1.0)
- Shape:
Note: Return audio data and sample rate.
audio_data: \((L)\) with tf.float32 dtype
sample_rate: tf.int32
- athena.transform.feats.read_wav.read_wav(wavfile, audio_channels=1)¶
Read wav from file. Can be called directly without ReadWav class.
- Examples::
>>> audio_data, sample_rate = read_wav('test.wav', audio_channels=1)