recognize_google fails with WinError 10060

18 Views Asked by At

I'm encountering a TimeoutError: [WinError 10060] while attempting to establish a connection in my Python program. This error arises when the connected party does not respond properly within a specific time frame, or when the established connection fails due to the connected host not responding. I think that recognize_google has something with it, because the program stops at this point: text = recognizer.recognize_google(audio)

Code Sample:


import speech_recognition as sr
    
    # Initialize the recognizer
    recognizer = sr.Recognizer()
    
    # Capture audio from the microphone
   
        with sr.Microphone() as source:
            print("Speak something...")
            audio = recognizer.listen(source)
    
        try:
            # Use the recognizer to convert speech to text
            text = recognizer.recognize_google(audio)
            print("You said:", text)
        except sr.UnknownValueError:
            print("Sorry, could not understand audio.")
        except sr.RequestError as e:
            print("Could not request results; {0}".format(e))

Error Message:

TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Additional Context: Python Version: 3.7 PyAudio: 0.2.11 playsound: 1.2.2

0

There are 0 best solutions below