1

hi i have a code that gives me an ALSA error so here is the code and i tried everything that i have known .farther more i installed and tried everything so if you can help it would be a fantastic opportunity for us to know each other so i can learn alot from you because i am still a beginner
so here is the code

 import webbrowser
    import string
    import speech_recognition as sr

    r = sr.Recognizer()
    with sr.Microphone() as source:
        print("Hello, what can i help you find?[Player lookup,Weather,resturants, or just to search the web: ]")
        audio = r.listen(source)




    if "player" in r.recognize_google(audio):
        # obtain audio from the microphone
        r2 = sr.Recognizer()
        url = 'https://en.wikipedia.org/wiki/'
        with sr.Microphone() as source:
            print("Say any sports players name to see there Bio: ")
            audio2 = r2.listen(source)

            try:
                print("Google Speech Recognition thinks you said " + r2.recognize_google(audio2))
                webbrowser.open_new(url+r2.recognize_google(audio2))
            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 "weather" in r.recognize_google(audio):
        # obtain audio from the microphone
        r3 = sr.Recognizer()
        url3 = 'https://www.wunderground.com/us/'
        with sr.Microphone() as source:
            print("Please say a city and state: ")
            audio3 = r3.listen(source)

            try:
                print("Google Speech Recognition thinks you said " + r3.recognize_google(audio3))
                webbrowser.open_new(url3+r3.recognize_google(audio3))
            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 "restaurants" in r.recognize_google(audio):
        # obtain audio from the microphone
        r4 = sr.Recognizer()
        url4 = 'https://www.yelp.com/search?cflt=restaurants&find_loc='
        with sr.Microphone() as source:
            print("Please state a location to search for restaurants: ")
            audio4 = r4.listen(source)

            try:
                print("Google Speech Recognition thinks you said " + r4.recognize_google(audio4))
                webbrowser.open_new(url4+r4.recognize_google(audio4))
            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 "search" in r.recognize_google(audio):
        # obtain audio from the microphone
        r5 = sr.Recognizer()

        with sr.Microphone() as source:
            print("what website would you like me to search for you? ")
            audio5 = r5.listen(source)
            url5= r5.recognize_google(audio5)

            try:
                print("Google Speech Recognition thinks you said " + r5.recognize_google(audio5))
                webbrowser.open_new("https://"+url5+".com")
            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)) 

and here is the error

ALSA lib pcm_dsnoop.c:606:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Hello, what can i help you find?[Player lookup,Weather,resturants, or just to search the web: ]

so if you can help i would be more than happy and thanks for your time

  • Could you be more specific about what all you've tried to resolve the error? – anishthecoder Mar 09 '18 at 18:33
  • @anishthecoder i tried to stop ALSA and reinstalled the pyaudio and speech recognition and upgraded the pip and pyaudio – Majd Barghouti Mar 09 '18 at 18:50
  • Those are not actual errors, they are just some messages from ALSA/PortAudio, see https://stackoverflow.com/q/36956083/. – Matthias Mar 10 '18 at 08:19
  • so how can i run the code if those messages keep popping up – Majd Barghouti Mar 11 '18 at 11:09
  • @Matthias if you can help please do as soon as possible – Majd Barghouti Mar 11 '18 at 11:33
  • You can just ignore the messages or look at the link I've provided how to silence them. I don't know anything about `speech_recognition`, but I can give you some general tips: Check if there is a tag for `speech_recognition` and use that for your question. Try to make your code *much* shorter, see https://stackoverflow.com/help/mcve. – Matthias Mar 11 '18 at 11:42
  • @Matthias can you help me silence this code and run it – Majd Barghouti Mar 11 '18 at 12:56
  • Sure, as soon as you have done the things I've suggested. – Matthias Mar 11 '18 at 13:22
  • @Matthias i tried to shorten my code but it was on the limit so if i change anything it would break and i did put the speech recognition tag – Majd Barghouti Mar 11 '18 at 13:37
  • You can *definitely* get rid of most of the code! You are repeating basically the same thing 4 times! Get rid of everything related to `webbrowser` (unless it is the cause of your problem). Please also fix the indentation. Try to find out how much of the code is actually executed, e.g. by putting in even more `print()` calls. – Matthias Mar 11 '18 at 13:57

0 Answers0