pythonaudiospeech-recognitionaudio-processingpython-sounddevice

No mic get detected as sound.query_devices() returns empty list?


Im trying to get the feed of the mic using "sounddevice" library in Python.

import sounddevice as sd 
print(sd.query_devices())

But it returns empty list.

I tried arecord -f cd -d 6 test.wav to record a voice note and it works fine. Also i checked the mic using online voice recorder tools where the mic works fine. Any idea what could be the possible error ?


Solution

  • Building port audio from the source solved the issue.

    Download the latest stable version of PortAudio Library from http://www.portaudio.com/download.html and extract it.

    Create a subfolder named usr inside and another folder src inside the usr folder, Navigate to this folder open the terminal and get root access using the command sudo su root or su root. folder.

    Execute the following commands: ./configure (make sure that ALSA library is set to YES), make, make install, and ldconfig.

    enter image description here

    for more detailed explanation follow this https://medium.com/@niveditha.itengineer/learn-how-to-setup-portaudio-and-pyaudio-in-ubuntu-to-play-with-speech-recognition-8d2fff660e94