Skip to content

Instantly share code, notes, and snippets.

@asadamatic
Created April 14, 2020 11:12
Show Gist options
  • Save asadamatic/458541c7f0ddad97a97b8117b2800703 to your computer and use it in GitHub Desktop.
Save asadamatic/458541c7f0ddad97a97b8117b2800703 to your computer and use it in GitHub Desktop.
Python script to record audio using 'sounddevice' module.
import sounddevice as sound
from scipy.io.wavfile import write
duration = 5
sampleRate = 4100
sound.default.samplerate = sampleRate
sound.default.channels = 2
recording = sound.rec(int(duration * sampleRate))
sound.wait()
write('sound.wav', sampleRate, recording)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment