List all the Microphones connected to System in Python using PyAudio and SpeechRecognition

In this article, we are going to get the List ID and index of the microphones attached to the system. One should have knowledge about microphone ID while dealing with microphones in the Python programs. So in order to get the list of microphones attached to the system we need the following Libraries.

  • Speechrecognition
  • PyAudio


  • SpeechRecognition: This module does not comes built-in with Python. There are two ways to install this module.
    1) Type the below command in the terminal.

    pip install SpeechRecognition

    2) Download resources from PyPI and extract it in a folder and then run following command in cmd or terminal.

    python install
  • PyAudio:
    1) Windows: Run the following command in the CMD.

    pip install pyaudio

    2) Linux: Run the following command in the terminal.

    sudo apt-get install python-pyaudio python3-pyaudio

Listing all the microphones connected

First of all import speechrecognition instance as ‘sr’

import speech_recognition as sr

Now list_microphone_names() method will return a array/list of the connected microphones to the system.


Complete Code:





import speechrecognition as sr



[‘HDA Intel PCH: ALC255 Analog (hw:0, 0)’, ‘HDA Intel PCH: HDMI 0 (hw:0, 3)’, ‘HDA Intel PCH: HDMI 1 (hw:0, 7)’, ‘HDA Intel PCH: HDMI 2 (hw:0, 8)’, ‘HDA Intel PCH: HDMI 3 (hw:0, 9)’, ‘HDA Intel PCH: HDMI 4 (hw:0, 10)’, ‘sysdefault’, ‘front’, ‘surround40’, ‘surround51’, ‘surround71’, ‘hdmi’, ‘pulse’, ‘dmix’, ‘default’]

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Hi there I am a student of CGC COE, Landran in CSE department and have a great interest in programming

If you like GeeksforGeeks and would like to contribute, you can also write an article using or mail your article to See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at to report any issue with the above content.