本文介绍了将游戏的输出以centos管道传输到记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自动化Websocket客户端的一些测试。该客户端根据命令连接到服务器,该服务器基本上是对文本引擎的语音。客户端支持来自麦克风的音频流,因此人们可以实时记录自己并将其传输到引擎。我在没有物理声卡的centos VM中运行客户端,因此我决定使用

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
arecord test.raw -r 8000 -t raw

以便我可以使用它来模拟麦克风功能。我在线阅读了有关ALSA的文件插件,可以将一个命令的结果传递到下一个命令,因此我对根目录中的.asoundrc文件进行了以下修改:

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
}

当我尝试以下命令时:

aplay audioFile.raw -D Ted

似乎运行良好,但test.raw的输出似乎只包含沉默...有谁知道我在做错什么,我对ALSA很陌生,所以如果有人可以指出我正确的方向,将不胜感激。谢谢!

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!

推荐答案

问题已解决,不是使用snd-dummy,而是使用snd-aloop和正确的音频管道来引用此问题:

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

这篇关于将游戏的输出以centos管道传输到记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 16:32