Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.

Home Page:https://pypi.python.org/pypi/SpeechRecognition/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Weird output when initializing mic, on Raspberry Pi 0W

pyIronManCoder opened this issue · comments

Steps to reproduce

  1. Everytime I run this code:
    `import speech_recognition as sr
    import time
    import gpiozero as gpio
    led = gpio.PWMLED(27)
    r = sr.Recognizer()
    def Recognize():
    with sr.Microphone() as source:
    r.adjust_for_ambient_noise(source)
    print("Say something!")
    r.pause_threshold = 0.5
    audio = r.listen(source, timeout=3, phrase_time_limit=5)
    try:
    print("recognizing")
    command = r.recognize_google(audio, language= "en-in")
    print(command)
    print("Google Speech Recognition thinks you said:" + command)
    except sr.UnknownValueError:
    print("Google Speech Recognition could not understand audio")
    except sr.RequestError as e:
    print("Could not request results from Google Speech Recognition service; {0}".format(e))
    if "lumos" in command:
    if "Maxima" in command:
    led.value = 1
    else:
    led.value = 0.3
    print("Lumos")
    if "lomo" in command:
    if "Maxima" in command:
    led.value = 1
    else:
    led.value = 0.3
    print("Lumos")
    if "lumo" in command:
    if "Maxima" in command:
    led.value = 1
    else:
    led.value = 0.3
    print("Lumos")
    if "moon" in command:
    if "Maxima" in command:
    led.value = 1
    else:
    led.value = 0.3
    print("Lumos")
    if "locks" in command:
    print("nox")
    led.value = 0
    if "KNOX" in command:
    print("knox")
    led.value = 0
    if "no" in command:
    print("knox")
    led.value = 0

while True:
Recognize()`
2. I am running this on a Raspberry Pi 0 w using a bluetooth headphone microphone
Expected behaviour

It should run and listen continuously.

Actual behaviour

It is giving some weird output like this
ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback ALSA lib conf.c:5200:(snd_config_expand) Unknown parameters {AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0} ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0} ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM dmix ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM sysdefault ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958 ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port ALSA lib pcm_a52.c:823:(_snd_pcm_a52_open) a52 is only for playback ALSA lib conf.c:5200:(snd_config_expand) Unknown parameters {AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0} ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM iec958:{AES0 0x6 AES1 0x82 AES2 0x0 AES3 0x2 CARD 0} ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_hw.c:1829:(_snd_pcm_hw_open) Invalid value for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory ALSA lib conf.c:5233:(snd_config_expand) Evaluate error: No such file or directory ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM dmix

BTW this happens everytime when "Say Something" is printed when run in loop. It delays the time it starts taking input, thus it isn't continuously listening. Is there any way to disable these info/warnings. But my mic works just fine, Thanks a lot for this great Library
System information

(Delete all the statements that don't apply.)

My system is Raspberry Pi latest x32 bit. (For example, "Ubuntu 16.04 LTS x64", "Windows 10 x64", or "macOS Sierra".)

My Python version is Python 3.9.2. (You can check this by running python -V.)

My Pip version is pip 20.3.4. (You can check this by running pip -V.)

My SpeechRecognition library version is 3.10.0. (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)

My PyAudio library version is 0.2.13 / I don't have PyAudio installed. (You can check this by running python -c "import pyaudio as p;print(p.__version__)".)

My microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())".)

My working microphones are: (same warnings as metioned before then) {1: 'default'} (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())".)