Sunday, January 5, 2020

python audio record (mac osX 10.4.6 Majov)

python audio record (mac osX  10.4.6 Majov)


import sounddevice as sd
from scipy.io.wavfile import write
duration = 10.5  # seconds

fs = 16000
try:
    myrecording = sd.rec(int(duration * fs), samplerate=fs, channels=1) # 2 did not work, but 1 works.
    sd.wait()  # Wait until recording is finished
    write('output.wav', fs, myrecording)  # Save as WAV file
except:
    pass

No comments:

Post a Comment