I am trying to make wedding guest answer phone for my sister. The basic idea of these things is you pick up the handset, hear a message from the host, leave you own, replace the handset, and the recording stops and saves. I have set all of the hardware up fine, it works, but as I have essentially no experience with coding getting all of the individual aspects to work is my issue.
For the recording aspect I tried a few different ways, they all ended up giving error codes that I couldn't find fixes for or crashing. Scipy seems to work the best, I have been using this for 5 second test recordings.
import sounddevice as sd from scipy.io.wavfile import write import wavio as wv import uuid freq = 44100 duration = 5 recording = sd.rec(int(duration * freq), samplerate=freq, channels=2) sd.wait() write("recording0_"+str(uuid.uuid4())+".wav", freq, recording)
The main issue is these messages are only 5 seconds, I don't know how to make them start recording after the host message and stop when the handset is replaced. Does anyone know how to modify this to make it record whilst a button is pressed?
If this helps I'm using a Raspberry pi 4 and Python 3.9.2.