Piping output from aplay to arecord in centos

2019-07-09 12:00发布

I am trying to automate some tests for a websocket client. This client connects to a server on command and the server is basically a speech to text engine. The client supports audio streaming from a microphone, such that people can record themselves in real time and transmitting it to the engine. I am running the client in a centos VM which does not have a physical sound card so I decided to simulate one using

modprobe snd-dummy

My plan is to pipe the output of

aplay audioFile.raw

to the input of

arecord test.raw -r 8000 -t raw

so that I can use that simulate the microphone feature. I read online that the file plugin for ALSA can pipe the results of one command to the next so I made the following modifications to the .asoundrc file in my root directory:

pcm.!default {
    type hw
    card 0
}

pcm.Ted {
       type file
       slave mySlave
       file "| arecord test.raw -r 8000 -t raw"
}

pcm_slave.mySlave {
       pcm "hw:0,0"

}

ctl.!default {
        type hw
        card 0
}

When I try the following command:

aplay audioFile.raw -D Ted

It seems to run fine but the output of test.raw seems to contain only silence... Does anyone know what I am doing wrong, I am very new to ALSA so if anyone can point me in the right direction, it would be greatly appreciated. Thanks!

1条回答
Animai°情兽
2楼-- · 2019-07-09 12:04

Issue Fixed, instead of using snd-dummy I used snd-aloop and audio correctly pipes refer to this question:

Is it possible to arecord output from dummy card?

查看更多
登录 后发表回答