speech_recognition: Bad gateway errors using Google Speech Recognition service
Steps to reproduce
- Trying to transcribe polish voice files basing on code from examples. I have tried with default and my generated API key.
- `#!/usr/bin/env python3
import speech_recognition as sr
from os import path
AUDIO_FILE = path.join(path.dirname(path.realpath(file)), “test.flac”)
r = sr.Recognizer() with sr.AudioFile(AUDIO_FILE) as source: audio = r.record(source) # read the entire audio file
GOOGLE_KEY = “mykey” lang = “pl”
try: print("Google Speech Recognition thinks you said " + r.recognize_google(audio, key = GOOGLE_KEY, language=lang)) 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)) ` I use this file as test file - test.zip
Expected behaviour
Recognized polish text.
Actual behaviour
Every time i get the same error message: “Could not request results from Google Speech Recognition service; recognition request failed: Bad Gateway”
System information
My Python version is Python 2.7.11
My SpeechRecognition library version is 3.4.6
I don’t have PyAudio installed.
I don’t havePocketSphinx installed.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 22 (5 by maintainers)
Hey @Uberi - I think it has to do with the length of the audio input. I found that audio files above a minute tend to produce this error whereas audio files <30 seconds work pretty good.
@mtraton @sravanth @asachanfbd @vipinagrahari have you tried trimming your input audio?
Hi @hblanken,
I think you’re looking for
recognize_google_cloud
rather thanrecognize_google
. Google actually has two different offerings for this: Google Speech API and Google Cloud Speech API.Here’s the documentation: https://github.com/Uberi/speech_recognition/blob/master/reference/library-reference.rst#recognizer_instancerecognize_google_cloudaudio_data-credentials_json--none-language--en-us-preferred_phrases--none-show_all--false