I think your best option is looking for an alternative to googletrans. Note that you can send http requests to a translation api, you don’t need a dedicated python library for that.
Guna Sekha, try the following, Best regards . -Alejandro Samid
To address the compatibility issue between googletrans and recent versions of openai, you can switch to an alternative translation library. Here’s a step-by-step guide to update your project:
Remove googletrans from your requirements.txt file.
Choose an alternative translation library. Based on the search results, deep-translator is a good option as it’s actively maintained and offers multiple translation services.
Update your requirements.txt file to include the new library:
streamlit
openai
deep-translator
Update your code to use the new library. Here’s an example using deep-translator with Google Translate:
Install the new library in your development environment:
pip install deep-translator
Test your updated code to ensure it works as expected.
Commit the changes to your GitHub repository.
Re-deploy your Streamlit app to apply the changes.
Using deep-translator offers several advantages:
It supports multiple translation services, including Google Translate, Microsoft Translator, and others.
It can be used directly from the terminal.
It supports batch translations.
It allows translations from text files.
However, note that language detection with deep-translator requires a private API key.
By following these steps, you should resolve the compatibility issue between googletrans and openai while maintaining the translation functionality in your Streamlit app.