Search code examples
pythongoogle-cloud-platformraspberry-pispeech

80 second delay using Google Cloud SpeechRecognition with python 3.9 on RPi3B+


I'm using the PyPi code ( https://pypi.org/project/SpeechRecognition/)

  • cleaned up to use only Google Cloud SpeechRecognition.
  • Google Json Credentials in shell's environment, and working.

I've enabled the Cloud Speech-to-Text API, got the Json credentials, and the service calls ARE hitting the API. The Microphone is fine, and the recording bit happens quickly.

However, its taking fully 80 seconds to perform the API call!

I've monitored the network traffic, and I can see that the API connection kinda sits idle for 78 seconds, and then TX/RXs really fast in the final 2 seconds. How can I speed this up?

Can it be slow-authentication handshake that I might mend?

MORE INFORMATION: My application performs 3 API calls: Google Speech-to-text | Google Translate text-to-text | Google text-to-Speech. Those API Calls ALWAYS take 80 seconds , 20s & 80s respectively.

Thanks a mil!

The delay happens on the 2nd last line here:

print("0 seconds")
try:
    print("Google Cloud Speech thinks you said " + r.recognize_google_cloud(audio)
print("80th second")

Solution

  • Problem solved! It was the SSL certs; bouquets to @Dean Van Greune & @VonC My fibre router (Sagemcom) was blocking the Pi's SSL certs, or forcing it to a different port, creating massive delays. I remember solving the same problem for JavaMail TLS a while back, and wanting to take the bat to the router ("Office Space"-style). Swapping to the hotspot on my phone, all this is working faster than the lightiest lightning now. Thanks for your help & suggestions guys!!!