Replies: 8 comments 9 replies
-
I am having the same issue, is anybody planning to fix this? I use WSL to test applications before I deploy them to edge compute platforms. |
Beta Was this translation helpful? Give feedback.
-
Please see #9896 for additional information. I have it running successfully with many ALSA lib messages being displayed. |
Beta Was this translation helpful? Give feedback.
-
At the time being, has anyone succeeded to have pyaudio working in WSL2? |
Beta Was this translation helpful? Give feedback.
-
Hey guys, some progress on my side! I found out that if I run The following works if I run it with import speech_recognition as sr
for index, name in enumerate(sr.Microphone.list_microphone_names()):
print("Microphone with name \"{1}\" found for `Microphone(device_index={0})`".format(index, name)) I have tried adding I also found out that the pulse audio server from #this works
arecord test.wav
aplay test.wav
#this doesn't
sudo arecord test.wav
sudo aplay test.wav Maybe @EdSeymore this shines some light for others to come up with the missing pieces. But I feel it should be working... On a side note, I recompiled the linux kernel enabling arecord -l
arecord: device_list:274: no soundcards found...
sudo arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Dummy [Dummy], device 0: Dummy PCM [Dummy PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
|
Beta Was this translation helpful? Give feedback.
-
If it will be of help to anyone, following worked for me after a lot of debugging in Ubuntu with wls and os version: |
Beta Was this translation helpful? Give feedback.
-
If it helps anyone, I think the confusion is due to difference in steps needed for WSL 1 and WSL2, and also due to the required setup on Windows firewall to allow incoming requests to the PulseAudio server running on Windows. I used following python code to debug if I can access audio devices from my WSL. I saved it in as file and ran it from WSL cmdline.
As per various old tutorials, we need to follow certain installations on Windows and also on WSL. However, I found that if you are having Windows 11 and WSL 2, you need not install packages on WSL (pulseaudio pulseaudio-utils packages). Also I found that PulseAudio zip on freedesktop.org and installation steps does not work on Windows 11. Following steps worked for me- The setup using the zip file given at https://www.freedesktop.org/wiki/Software/PulseAudio/ did not work. I could get the pyaudio service started but WSL was not able to access audio. So I cleaned up the manual installation of PulseAudio on Windows, and reinstalled PulseAudio as a service with Full Installer at https://www.freedesktop.org/wiki/Software/PulseAudio/. The Full installer also help to setup access with Windows Firewall.
After this, run the test script above on WSL comdline and you should see |
Beta Was this translation helpful? Give feedback.
-
For me https://github.com/bastibe/SoundCard works fine in WSL2. |
Beta Was this translation helpful? Give feedback.
-
Hey folks, I was able to get it pyaudio Mic input running on WSL2. I used GPTs help, as such, I don't deeply understand the individual steps. However, I am sharing the steps taken below in case it helps someone: WSL2/WSLg: Fix PyAudio mic error “[Errno -9996] Invalid input device (no default output device)” (Deepgram or any PyAudio app)
Steps
test -S /mnt/wslg/PulseServer && echo "WSLg OK" || echo "No WSLg"
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
libportaudio2 libasound2t64 libasound2-plugins alsa-utils pulseaudio-utils
cat > ~/.asoundrc <<'EOF'
pcm.!default { type pulse fallback "sysdefault" hint.description "Default Audio Device (via PulseAudio)" }
ctl.!default { type pulse fallback "sysdefault" }
EOF
echo 'export PULSE_SERVER=unix:/mnt/wslg/PulseServer' >> ~/.bashrc
source ~/.bashrc
pactl info | sed -n '1,15p' # should show Default Source: RDPSource, Default Sink: RDPSink
pactl list sources short
arecord -D default -f S16_LE -c 1 -r 16000 -d 2 /tmp/test.wav && ls -lh /tmp/test.wav
uv run deepgram/live-streaming-starter-kit/test_suite.py -k <YOUR_DEEPGRAM_KEY> -i mic
uv run deepgram/live-streaming-starter-kit/test_suite.py -k <YOUR_DEEPGRAM_KEY> -i mic 2>/dev/null
Why this works
Quick troubleshooting
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Would like to access the microphone and speakers from python3 application. I tried various approaches without success. I also was unable to get gradio to function with python3 on ubuntu. Also, the speakers do not honor my request to default to HDMI speakers when a USB micropohne with an earphone port is present without the earphone attached.
Beta Was this translation helpful? Give feedback.
All reactions