我正在尝试创建一个虚拟麦克风来馈送其他需要音频输入的程序。我正在使用cheerupcharlie在2017年4月提出的解决方案 现在处理的方式是一旦写入管道,您必须打开另一个终端会话并从管道读取。然后它将再次写入管道(请参见脚本中的while循环)。我要做的是从主脚本执行python脚本(请参见循环中的注释)。然后返回再次写入管道。当前,它所做的只是在写入管道后挂起(仍在等待从另一个进程读取)
有什么建议吗?
这是脚本
#!/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.
rm /home/pi/audiofiles/virtmic
echo "Creating virtual microphone."
pactl load-module module-pipe-source source_name=virtmic file=/home/pi/audiofiles/virtmic format=s16le rate=44100 channels=2
# 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/pi/.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."
n=1
while (( $n <= 3))
do
ffmpeg -re -i testout.wav -f s16le -ar 44100 -ac 2 - > /home/pi/audiofiles/virtmic
echo "speechrec running"
# python3 speechrec.py
n=$(( n+1 ))
done