A container class for audio objects. Provides a Speect native class for creating/adding audio objects. The audio samples are internally represented as floats.
num_samples()
Return the number of samples of this audio object.
Returns: | Number of samples of this audio object. |
---|---|
Return type: | int |
sample_rate()
Return the sample rate of the samples of this audio object.
Returns: | Sample rate of this audio object (Hertz). |
---|---|
Return type: | int |
Return the waveform of this SAudio object in Python dict e.g.:
{'sampletype': 'int16',
'samplerate': 16000,
'samples': '...bytestring...samples....'}
Returns: | Audio waveform. |
---|---|
Return type: | dict |
Note : | Currently supports only ‘int16’ sample types. |
speect.audio also adds a method to play audio objects through dev/dsp to the speect.SUtterance class.
Play utterance waveform. Will do nothing if the utterance does not have an “audio” feature.
Note : | Uses SAudio.play() internally. |
---|
Note
This function first tries to import pyaudio (http://people.csail.mit.edu/hubert/pyaudio/), and use pyaudio for playback. If pyaudio is not available then on posix systems, it tries to open an audio device (environment variable AUDIODEV, or fallback /dev/dsp) and write 16 bit little endian values to it.