def _save_audio_data_to_disk(audiodata: AudioData): name = str(uuid.uuid4()) # GStreamer audioconverters may lost during the installation # So we use raw audioformat and it is cruicial to resample the audio at the proper rate (mfcc.conf) audio_data = audiodata.get_raw_data(convert_rate=8000) path = name + ".raw" with open(path, mode="wb") as f: f.write(audio_data) path = os.path.abspath(f.name) return path
def _get_audio(self, audio_data: AudioData): return audio_data.get_raw_data(self._convert_rate, self._convert_width)