mirror of
https://github.com/romanz/amodem.git
synced 2026-02-07 18:08:03 +08:00
19 lines
415 B
Python
19 lines
415 B
Python
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
|
|
|
|
|