I want to record voice, process it, than play it on the fly. The code below should describe more.
arecord -D plughw:USER -f S16_LE -t raw | python my_app.py | aplay -D plughw:USER -f S16_LE
I was able to capture input from arecord
for my_app.py
by using raw_input()
. Now, I have problem on how to send my_app.py
output to aplay
.
I've tried using subprocess
inside my_app.py
to run aplay
,
cmdPlay = 'aplay -D plughw:USER -f S16_LE'
p = subprocess.Popen(
cmdPlay,
stdout = subprocess.PIPE,
stdin = subprocess.PIPE,
stderr = subprocess.PIPE,
shell = True
)
p.communicate(input=dataHex.decode('hex'))
But, I heard no voice played on speaker.
So, how do you piping between python app and other processes (as input and output)?
n.b.: Please also suggest a better method, if any, than raw_input()
for capture data from arecord.