Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to google API when using recognize_google() #830

Open
Unknownuserfrommars opened this issue Mar 3, 2025 · 4 comments
Open
Assignees

Comments

@Unknownuserfrommars
Copy link

Steps to reproduce

My code
I used yt-dlp and some processessing and let SR recognize the text, but when i tried to call recognize_google(), an errored occured: Error reading video: Unable to connect Google API
Specifically, in this line of code.
Somehow, this error passed my try...except block for sr.UnknownValueError and sr.RequestError. Instead, it went to the end of the major try-except block starting from L277.
Was it my connection? But i double and triple-checked everything. Network no issue for me

Btw, as a reference, the link to my project is: https://lightningroute-fe.streamlit.app/

Expected behaviour

Recognize the audio and turn into text

Actual behaviour

Error

Error reading video: Unable to connect Google API

(This is hosted by streamlit, so i used a st.error() to display the error message instead of in the terminal)

System information

(Delete all the statements that don't apply.)

My system is Windows 11 24H2 (x64).

My Python version is 3.12.9 (In Streamlit Cloud).

My Pip version is Don't know, Streamlit Cloud doesn't have a interactive shell. (You can check this by running pip -V.)

My SpeechRecognition library version is 3.14.1.

My PyAudio library version is I don't have PyAudio installed.

@ftnext
Copy link
Collaborator

ftnext commented Mar 4, 2025

I searched the repositories of SpeechRecognition and yt-dlp with the error message "Unable to connect Google API", but I couldn't find it

@Unknownuserfrommars Try repr(e). I think you can display the error class.
https://github.com/Unknownuserfrommars/LightningRoute-Frontend/blob/99011f6bde28baf5060ef6dda76090b550c1d452/app.py#L324-L325

except Exception as e:
-    st.error(f"Error reading video: {str(e)}")
+    st.error(f"Error reading video: {repr(e)}")

Also please paste the entire stacktrace.

@ftnext
Copy link
Collaborator

ftnext commented Mar 4, 2025

It worked?

Video URL: https://www.youtube.com/watch?v=zm6F0vo2E64

Image

@Unknownuserfrommars
Copy link
Author

Okay thanks for your reply @ftnext I will take a look at it shortly. (And yes repr() is a good function, too bad i didn't think of it early. But will test if it works).
PS: Sorry for that UI. The div background should be white (because the text is black), I will work on it later too.)

@Unknownuserfrommars
Copy link
Author

Also, that URL did not work for me. Actually, NO URL works for me (both Youtube and Bilibili URLs (which i hope china's video platform might give me a result but no). I don't actually know why. Because I'm hosting this app so it fails only on me?
The error msg is: Error reading video: [Errno 2] No such file or directory: 'audio' → 'audio' Which... I don't actually quite get it.
I am still working on it tho. I think the error msg is these two lines: here I am still trying to figure out the base logic for this. Streamlit Cloud uses a Unix environment while I use the shitty windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants