I have tried to record the call (using twilio services) in django using sounddevice library. But after the call ends, the recording does not stop, it continues recording with the duration of sec that I have input. I want to stop the recording when call ends. Please give me any suggestion of this problem.
Here is my code.
def recording_call(request):
fs = 44100
duration = 30
print('recording...')
record_voice = sounddevice.rec(int(duration * fs), samplerate=fs, channels=2)
sounddevice.wait()
write("output2.wav", fs, record_voice)
file = "media/audio_call-%s.wav" % 23425
write(file, fs, record_voice)
with open(file, 'rb') as f:
print(f)
return HttpResponse('')