Open In App

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.

Installation

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.

sr.Microphone.list_microphone_names()

Complete Code:




import speechrecognition as sr
  
  
print(sr.Microphone.list_microphone_names())

Output:

[‘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’]

Article Tags :