Skip to content

Instantly share code, notes, and snippets.

@pragatibaheti
Created May 8, 2020 14:09
Show Gist options
  • Save pragatibaheti/a4245b9506147245b1189cbb98b7fe46 to your computer and use it in GitHub Desktop.
Save pragatibaheti/a4245b9506147245b1189cbb98b7fe46 to your computer and use it in GitHub Desktop.
import sounddevice as sd
import soundfile as sf
samplerate = 16000
duration = 1 # seconds
filename = 'mytest.wav'
print("start recording")
mydata = sd.rec(int(samplerate * duration), samplerate=samplerate,
channels=1, blocking=True)
print("end")
sd.wait()
sf.write(filename, mydata, samplerate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment