-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrecord.py
32 lines (25 loc) · 834 Bytes
/
record.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from turtle import goto
import sounddevice as sd
from scipy.io.wavfile import write
import numpy
def record():
#sampling frequency
freq = 48000
#recording duration
duration = 10
#start recorder with given values of duration and sampling frequency
recording = sd.rec(int(duration * freq),samplerate=freq, channels=2)
#Record audio for the given number of seconds
sd.wait()
#this will convert the numpy array to an audio file with the given sampling frequency
write("test_sample.wav",freq,recording.astype(numpy.float32))
#convert the numpy array to audio file
#write('test_sample.wav',freq,)
def run():
while(1):
val=input('Enter "s" to start recording')
if (val == 's'):
record()
break
else:
print('please enter s to start a 10 sec audio')