Skip to content

Instantly share code, notes, and snippets.

@aravindpai

aravindpai/record.py

Created Jul 10, 2019
Embed
What would you like to do?
import sounddevice as sd
import soundfile as sf
samplerate = 16000
duration = 1 # seconds
filename = 'yes.wav'
print("start")
mydata = sd.rec(int(samplerate * duration), samplerate=samplerate,
channels=1, blocking=True)
print("end")
sd.wait()
sf.write(filename, mydata, samplerate)
@sahanagiri

This comment has been minimized.

Copy link

@sahanagiri sahanagiri commented Jul 2, 2021

Sir, I am getting error in this line:
mydata = sd.rec(int(samplerate * duration), samplerate=samplerate,
channels=1, blocking=True)
PortAudioError: Error querying device -1
How to solve this. Please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment