Language Translator app is throwing up an error regarding JSONDecode

Hello all,

A few days ago, I deployed a Language Translator app.
The Language Translator app was going fine those days. When I checked this morning, It is showing a json.JSONDecode error.

ERROR:

json.decoder.JSONDecodeError: Extra data: line 1 column 798 (char 797)
Uncaught app exception
Traceback (most recent call last):
File โ€œ/home/appuser/venv/lib/python3.7/site-packages/streamlit/script_runner.pyโ€, line 338, in _run_script
exec(code, module.dict)
File โ€œ/app/languagetranslator/main.pyโ€, line 35, in
translate = translator.translate(text,lang_src=value1,lang_tgt=value2)
File โ€œ/home/appuser/venv/lib/python3.7/site-packages/google_trans_new/google_trans_new.pyโ€, line 188, in translate
raise e
File โ€œ/home/appuser/venv/lib/python3.7/site-packages/google_trans_new/google_trans_new.pyโ€, line 152, in translate
response = json.loads(response)
File โ€œ/usr/local/lib/python3.7/json/init.pyโ€, line 348, in loads
return _default_decoder.decode(s)
File โ€œ/usr/local/lib/python3.7/json/decoder.pyโ€, line 340, in decode
raise JSONDecodeError(โ€œExtra dataโ€, s, end)

Github repo: GitHub - harisankarsnair/LanguageTranslator: A web app for translating from one language to another.Almost all languages are available.App also generates an audio file of the translation and lets you download the audio file.

Live App: https://share.streamlit.io/harisankarsnair/languagetranslator/main/main.py

I donโ€™t know why this JSON error is being shown up suddenly.
Can anyone help me solve this problem?
Any help will be much appreciated.

Regards,
Harisankar.

Hey @HarisankarSNair,

Were you able to figure this out? It seems your app is up now and not displaying that JSON error.

Happy Streamlit-ing!
Marisa

1 Like

Hi all,

It is coming from a JSON issue at google_trans_new.py. I fixed at my local by making some changes at this file. For further information to fix at your local you may read this article. Its working properly on local: Python google-trans-new translate raises error: JSONDecodeError: Extra data: - Stack Overflow

But I could not find a way to work this on Streamlit host. Could somebody fix this issue?

Kind Regards,
Cagdas

1 Like

Hi @ekimdusu

Thank you for your reply. I will surely look into this.
Can you share a snippet of the code where you made changes?

I have also created a GitHub issue in my repo mentioning the same -Translating gives error ยท Issue #1 ยท HarisankarSNair/LanguageTranslator ยท GitHub

Regards
Harisankar

1 Like

Hi @HarisankarSNair, were you able to resolve it in Streamlit?
I am getting the JSONDecodeError

https://share.streamlit.io/tulasi-agina/translator/main/foreignlanguage.py
https://github.com/tulasi-agina/Translator/blob/main/foreignlanguage.py

regards
Tulasi

Hi @Tulasi_Agina,

I canโ€™t help you as it seems that your github repo and app are private. If you can allow me access to them I can take a look and see if I can help find the error.

Happy Streamlit-ing!
Marisa