简体   繁体   中英

What device I would select for Speech Recognition to use the audio coming out of my computer?

I'm trying to make a closed captions generator using Python 3. When I call list_microphone_names() , a bunch of audio sources are listed. Which source would I select for the audio that comes out of my computer?

I've tried using pocketsphinx for live recognition but the results are horribly inaccurate. I've found an option for using the -adcdev parameter to select a source but I don't know what to put into it.

Here is what I get from calling list_microphone_names() :

>>> import speech_recognition as sr
>>> r = sr.Recognizer()
>>> mic = sr.Microphone()
>>> sr.Microphone.list_microphone_names()
['Microsoft Sound Mapper - Input', 
'Microphone (HD Webcam C270)', 
'Microsoft Sound Mapper - Output', 
'Speakers (Realtek High Definiti', 
'Primary Sound Capture Driver', 
'Microphone (HD Webcam C270)', 
'Primary Sound Driver', 
'Speakers (Realtek High Definition Audio)', 
'Speakers (Realtek High Definition Audio)', 
'Microphone (HD Webcam C270)', 
'Line In (Realtek HD Audio Line input)', 
'Speakers (Realtek HD Audio output)', 
'Microphone (Realtek HD Audio Mic input)', 
'Stereo Mix (Realtek HD Audio Stereo input)', 
'Microphone (HD Webcam C270)']

I'm guessing Stereo Mix because this article explains how to record the sound coming from your computer without using Stereo Mix.

If it is possible for accurate, live speech recognition with speech_recognition for the audio that comes out of my computer, I'm all in for it.

Running Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32 .

Rather than listing all available microphones, consider using Microphone.list_working_microphones() that lists only those currently hearing sound. Make sure to make some noise, otherwise the function may return an empty list. After you got the list of working microphones, try them one by one and finally pick up the one with which recognition quality is the best.

The code snippet below simply picks the first one working:

for device_index in Microphone.list_working_microphones():
    m = Microphone(device_index=device_index)
    break
else:
    print("No working microphones found!")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM