Previous topic

speect.track_float – Floating Point Track

Next topic

speect.audio_riff – RIFF Audio Serialization

speect.audio – Waveform Container

class speect.audio.SAudio

A container class for audio objects. Provides a Speect native class for creating/adding audio objects. The audio samples are internally represented as floats.

SAudio.num_samples()

num_samples()

Return the number of samples of this audio object.

Returns:Number of samples of this audio object.
Return type:int
SAudio.sample_rate()

sample_rate()

Return the sample rate of the samples of this audio object.

Returns:Sample rate of this audio object (Hertz).
Return type:int
SAudio.get_audio_waveform()

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.

SUtterance.play()

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.