We will use two package 'sounddevice' and 'scipy.io.wavfile'
sounddevice is used to Play and Record Sound with Python and scipy.io.wavfile is used to write a NumPy array as a WAV file.
Read about the modules :
Code :
import sounddevice
from scipy.io.wavfile import write
fr = 44100 # frame rate
sec = int(input("Enter the time duration in seconds : "))
print("Recording.....\n")
record = sounddevice.rec(int(second * fs), samplerate=fs, channels=2)
sounddevice.wait()
write("out.wav", fr, record)
print("Finished....")
0 Comments
Ask Your Queries in the comments