我试图通过语音识别将文本中的语音转换,但是当我使用此命令python3 -m speech_recognition时,都无济于事
这是命令的输出
A moment of silence, please...
Set minimum energy threshold to 504.318206261492
Say something!
Got it! Now to recognize it...
Oops! Didn't catch that
Say something!
Got it! Now to recognize it...
You said Orange
Say something!
Got it! Now to recognize it...
Oops! Didn't catch that
这是无效的代码
import speech_recognition as sr
r=sr.Recognizer()
with sr.Microphone(device_index=1) as source:
print("say")
audio=r.listen(source)
query=r.recognize_google(audio)
print("you say "+query)
我试图检测此代码使用的麦克风
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))
这是输出,但所有这些都不起作用
Microphone with name "HDA Intel PCH: ALC271X Analog (hw:0,0)" found for `Microphone(device_index=0)`
Microphone with name "HDA Intel PCH: ALC271X Alt Analog (hw:0,2)" found for `Microphone(device_index=1)`
Microphone with name "HDA Intel PCH: HDMI 0 (hw:0,3)" found for `Microphone(device_index=2)`
Microphone with name "sysdefault" found for `Microphone(device_index=3)`
Microphone with name "front" found for `Microphone(device_index=4)`
Microphone with name "surround40" found for `Microphone(device_index=5)`
Microphone with name "surround51" found for `Microphone(device_index=6)`
Microphone with name "surround71" found for `Microphone(device_index=7)`
Microphone with name "hdmi" found for `Microphone(device_index=8)`
Microphone with name "pulse" found for `Microphone(device_index=9)`
Microphone with name "dmix" found for `Microphone(device_index=10)`
Microphone with name "default" found for `Microphone(device_index=11)`