I found an example that shows how to pass a wave file as microphone input by utilizing "pactl load-module module-pipe-source". The issue with this example is that it relies on an infinite while loop and does not stop when the audio file is success put through the microphone a single time. If someone can a fix to this example that would be great. I heard of: sudo modprobe snd-dummy But do not know how to use it. documentation is quite lacking.
The example is as follows:
# Load the "module-pipe-source" module to read audio data from a FIFO special file.
pactl load-module module-pipe-source source_name=virtmic
file=/home/cammy/audioFiles/virtmic format=s16le rate=16000 channels=1
# Set the virtmic as the default source device.
pactl set-default-source virtmic
# 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 good_morning_vietnam.wav > /home/cammy/audioFiles/virtmic
done
The result of this as you can imagine is that the audio clip is continuously looped repeatedly. I only want this played once, not many times. If i try line:
cat good_morning_vietnam.wav > /home/cammy/audioFiles/virtmic
outside of the while loop. It appears that only a tiny sample of the audio file reaches the microphone, not the entire clip. I have no idea why this is the case. Not sure if like the mic file is regularly purged or something.