'Speech Recognition return 'Bad Request'

I use Speech Recognition and input raw data via Microphone. And also I use Recognizer_google to do speech to text. But it return an error called Bad Request.

import speech_recognition as sr

r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

try:
    print("Google Speech Recognition thinks you said " + r.recognize_google(audio))
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 the error is:

Say something!
Could not request results from Google Speech Recognition service; recognition request failed: Bad Request


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source