How to get PyAudio to continuously record?

Viewed 76

I'm trying to get PyAudio to record continuously until the program ends. I've tried to remove the amount of time to record for, but all that does is record it for only one second and make the first sample of sound loop. Here is my code

import sounddevice as sd
from scipy.io.wavfile import write

fs = 44100  # Sample rate
seconds = 3  # Duration of recording

myrecording = sd.rec(int(fs), samplerate=fs, channels=2)
sd.wait()  # Wait until recording is finished
write('insert name of output file here.wav', fs, myrecording)  # Save as WAV file
0 Answers
Related