diff --git a/test_audioinput.py b/test_audioinput.py index 779ef3a..213e1a4 100644 --- a/test_audioinput.py +++ b/test_audioinput.py @@ -2,11 +2,13 @@ """ test_audioinput.py -Quick sanity check to ensure audio input device is working. -Records 2 seconds of audio from default input and plots waveform. +Records 2 seconds of audio from the default input device +and saves the waveform as 'waveform.png' — works headless. """ import numpy as np +import matplotlib +matplotlib.use('Agg') # Headless backend import matplotlib.pyplot as plt import sounddevice as sd @@ -21,7 +23,7 @@ sd.wait() # Generate time axis time_axis = np.linspace(0, DURATION, len(recording)) -# Plot +# Plot and save plt.figure(figsize=(10, 4)) plt.plot(time_axis, recording, linewidth=0.5) plt.title("Audio Input Waveform") @@ -29,4 +31,6 @@ plt.xlabel("Time [s]") plt.ylabel("Amplitude") plt.grid(True) plt.tight_layout() -plt.show() +plt.savefig("waveform.png") + +print("✅ Waveform saved as 'waveform.png'")