Ich bin nicht 100% sicher, aber ich glaube, ich hatte dieses Problem eine Weile zurück, und es könnte etwas sein, mit dem zu tun, Mikrofonquelle. Sie können das Problem beheben, indem ...
Änderung alle Instanzen Mikrofon() zu Mikrofon (device_index = MICROPHONE_INDEX), wobei MICROPHONE_INDEX die hardwarespezifischen Index des Mikrofons ist
Um herauszufinden, was den Wert von MICROPHONE_INDEX sein sollte, führen Sie den folgenden Code ein:
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))
Dies wird in etwa wie folgt ausdrucken: Jetzt
Microphone with name "HDA Intel HDMI: 0 (hw:0,3)" found for `Microphone(device_index=0)`
Microphone with name "HDA Intel HDMI: 1 (hw:0,7)" found for `Microphone(device_index=1)`
Microphone with name "HDA Intel HDMI: 2 (hw:0,8)" found for `Microphone(device_index=2)`
Microphone with name "Blue Snowball: USB Audio (hw:1,0)" found for `Microphone(device_index=3)`
Microphone with name "hdmi" found for `Microphone(device_index=4)`
Microphone with name "pulse" found for `Microphone(device_index=5)`
Microphone with name "default" found for `Microphone(device_index=6)`
, für Prüfung Wenn Sie das Schneeballmikrofon verwenden möchten, wechseln Sie Mikrofon() zu Mikrofon (Gerät_index = 3).
Ich hoffe, das :) half
im Tutorial sie die Shebang '# verwendet!/Usr/bin/env python3', so dass sie python3 verwendet. Vielleicht haben Sie ein inkonsistentes Modul für python2.7. Hast du irgendeinen Fehler bekommen? Returned 'r.listen (source)' eine Audio-Instanz? – bierschi
Versuchen Sie 'python -m rede_recognition' auszuführen und sehen Sie, ob es funktioniert und Ihre Wörter erkennt. –