From fd1fa138d98883cf4a71a61186a02e0b8453d1a3 Mon Sep 17 00:00:00 2001 From: jpunkt Date: Thu, 4 Nov 2021 15:04:12 +0100 Subject: [PATCH] Reverting sound recording to wav. --- pizzactrl/hal_serial.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pizzactrl/hal_serial.py b/pizzactrl/hal_serial.py index f2ee658..7480f2c 100644 --- a/pizzactrl/hal_serial.py +++ b/pizzactrl/hal_serial.py @@ -4,7 +4,7 @@ from time import sleep from enum import Enum from typing import Any, List -# from scipy.io.wavfile import write as writewav +from scipy.io.wavfile import write as writewav import pydub import sounddevice as sd @@ -215,10 +215,10 @@ def record_sound(hal: PizzaHAL, filename: Any, duration: int, else: sd.wait() # Wait until recording is finished # TODO test - myrecording = np.int16(myrecording) - song = pydub.AudioSegment(myrecording.tobytes(), frame_rate=AUDIO_REC_SR, sample_width=2, channels=2) - song.export(str(filename), format="mp3", bitrate="320k") - # ALTERNATIVE writewav(str(filename), AUDIO_REC_SR, myrecording) + # myrecording = np.int16(myrecording) + # song = pydub.AudioSegment(myrecording.tobytes(), frame_rate=AUDIO_REC_SR, sample_width=2, channels=2) + # song.export(str(filename), format="mp3", bitrate="44.1k") + writewav(str(filename), AUDIO_REC_SR, myrecording) if cache: hal.soundcache[str(filename)] = (myrecording, AUDIO_REC_SR)