经过数小时的辛苦工作,我终于得到了可以接受的工作。我撤消了我对ALSA所做的所有操作(因为默认情况下,ALSA改用PulseAudio代替了它,而我最初将其覆盖)。我创建了一个简单的bash脚本,
install_virtmic.sh以创建一个供PulseAudio以及PulseAudio客户端使用的“虚拟麦克风”:
#!/bin/bash# This script will create a virtual microphone for PulseAudio to use and set it as the default device.# Load the "module-pipe-source" module to read audio data from a FIFO special file.echo "Creating virtual microphone."pactl load-module module-pipe-source source_name=virtmic file=/home/charles/audioFiles/virtmic format=s16le rate=16000 channels=1# Set the virtmic as the default source device.echo "Set the virtual microphone as the default device."pactl set-default-source virtmic# Create a file that will set the default source device to virtmic for all PulseAudio client applications.echo "default-source = virtmic" > /home/charles/.config/pulse/client.conf# Write the audio file to the named pipe virtmic. This will block until the named pipe is read.echo "Writing audio file to virtual microphone."while true; do cat audioFile0.raw > /home/charles/audioFiles/virtmicdone
uninstall_virtmic.sh撤消安装脚本完成的所有操作的快速脚本:
#!/bin/bash# Uninstall the virtual microphone.pactl unload-module module-pipe-sourcerm /home/charles/.config/pulse/client.conf
然后,我启动Chromium,然后单击麦克风以使用其语音搜索功能,它可以正常工作!我也尝试过
arecord test.raw -t raw -fS16_LE -c 1 -r16000,它也起作用!这不是完美的,因为我一直
virtmic在脚本的无限循环中写入命名管道(这很快使我的
test.raw文件变得异常大),但是现在就可以了。
如果有任何人找到更好的解决方案,请随时告诉我!



