mirror of
https://github.com/romanz/amodem.git
synced 2026-03-27 21:39:06 +08:00
Move wave play/record into separate module.
This commit is contained in:
18
wave.py
Normal file
18
wave.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import os
|
||||
import signal
|
||||
import subprocess as sp
|
||||
|
||||
from common import Fs
|
||||
|
||||
def play(fd):
|
||||
args = ['aplay', fd.name, '-q', '-f', 'S16_LE', '-c', '1', '-r', str(int(Fs))]
|
||||
ret = sp.call(args=args)
|
||||
assert ret == 0
|
||||
|
||||
def record(fname):
|
||||
args = ['arecord', fname, '-q', '-f', 'S16_LE', '-c', '1', '-r', str(int(Fs))]
|
||||
p = sp.Popen(args=args)
|
||||
p.stop = lambda: os.kill(p.pid, signal.SIGINT)
|
||||
return p
|
||||
|
||||
|
||||
Reference in New Issue
Block a user