You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
555 B
Python
31 lines
555 B
Python
5 years ago
|
#!/usr/bin/env python3
|
||
|
import subprocess
|
||
|
import shlex
|
||
|
import os
|
||
|
from datetime import datetime
|
||
|
from time import sleep
|
||
|
|
||
|
now = datetime.now().strftime('%Y%m%d-%H%M%S')
|
||
|
home_path = os.path.abspath(__file__)
|
||
|
#recordings_path = home_path + '/audios/'
|
||
|
recordings_path ='audios/'
|
||
|
recording_file = recordings_path + now + '.wav'
|
||
|
|
||
|
print(recording_file)
|
||
|
|
||
|
cmd = "arecord -f cd -D hw:1,0 {}".format(recording_file)
|
||
|
cmd = shlex.split(cmd)
|
||
|
|
||
|
# start recording
|
||
|
rec = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=False)
|
||
|
|
||
|
|
||
|
sleep(5)
|
||
|
|
||
|
|
||
|
|
||
|
# stop recording
|
||
|
rec.kill()
|
||
|
|
||
|
|