diff --git a/recorded_audio.wav b/recorded_audio.wav new file mode 100644 index 0000000..40e70e2 Binary files /dev/null and b/recorded_audio.wav differ diff --git a/wav_recorder.py b/wav_recorder.py new file mode 100644 index 0000000..289e9db --- /dev/null +++ b/wav_recorder.py @@ -0,0 +1,29 @@ +import wave +import numpy as np + +FIFO_PATH = "/tmp/esp32_audio" +OUTPUT_FILE = "recorded_audio.wav" + +SAMPLE_RATE = 16000 +CHANNELS = 2 # stereo from ESP32 +BYTES_PER_SAMPLE = 2 + +# configure WAV writer +out_wav = wave.open(OUTPUT_FILE, "wb") +out_wav.setnchannels(CHANNELS) +out_wav.setsampwidth(BYTES_PER_SAMPLE) +out_wav.setframerate(SAMPLE_RATE) + +with open(FIFO_PATH, "rb") as f: + print(f"Recording from {FIFO_PATH} into {OUTPUT_FILE}...") + try: + while True: + data = f.read(8000) # ~0.125s stereo + if not data: + continue + out_wav.writeframes(data) + except KeyboardInterrupt: + print("\nStopping recording.") + finally: + out_wav.close() + print(f"Saved {OUTPUT_FILE}")