Created
January 28, 2021 09:27
-
-
Save gerritjvv/939a97e2562cdaa5644d5d42f709013f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# pip3 install sounddevice --user | |
# pip3 install numpy | |
# pip3 install scipy | |
import sounddevice as sd | |
import numpy as np | |
fs=44100 | |
duration = 5 # seconds | |
myrecording = sd.rec(duration * fs, samplerate=fs, channels=2,dtype='float64') | |
print("Recording Audio") | |
sd.wait() | |
print("Audio recording complete , Play Audio") | |
sd.play(myrecording, fs) | |
sd.wait() | |
print(f"Type {type(myrecording)} shape {myrecording.shape}") | |
print(f"value {myrecording[0]}") | |
with open('./myrecording', 'wb') as file: | |
np.save(file, myrecording) | |
print("Play Audio Complete") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment