LangToLang is a language translation web application built using Streamlit and Hugging Face's MarianMT models. It allows users to translate text between various languages, including English, French, German, Spanish, Italian, Russian, Chinese, Japanese, Korean, Arabic, and Urdu.
- Translate Text: Easily translate text between multiple languages.
- Language Selection: Choose source and target languages from a variety of options.
- User-Friendly Interface: A clean and intuitive interface built with Streamlit.
- Real-Time Translation: Get instant translation results as you type.
- Installation
- Usage
- Model Information
- Hugging Face Models
- Deployed Application
- How to Achieve the Same
- Contributing
- License
- Contact
-
Clone the Repository:
git clone https://github.com/[Your GitHub Username]/LangToLang.git cd LangToLang
-
Install the Required Packages:
pip install -r requirements.txt
-
Run the Application:
streamlit run app.py
- Select the source and target languages from the sidebar.
- Enter the text you wish to translate in the text area.
- Click the "Translate" button to see the translated text.
LangToLang uses Hugging Face's MarianMT models for translation. These models are pre-trained for various language pairs and provide accurate and efficient translations.
- Helsinki-NLP/opus-mt-en-fr (English to French)
- Helsinki-NLP/opus-mt-en-de (English to German)
- Helsinki-NLP/opus-mt-en-es (English to Spanish)
- Helsinki-NLP/opus-mt-en-it (English to Italian)
- Helsinki-NLP/opus-mt-en-ru (English to Russian)
- Helsinki-NLP/opus-mt-en-zh (English to Chinese)
- Helsinki-NLP/opus-mt-en-ja (English to Japanese)
- Helsinki-NLP/opus-mt-en-ko (English to Korean)
- Helsinki-NLP/opus-mt-en-ar (English to Arabic)
- Helsinki-NLP/opus-mt-en-ur (English to Urdu)
Try out the live version of LangToLang:
-
Choose a Model on Hugging Face:
- Go to the Hugging Face Model Hub and search for MarianMT models or any other translation models.
-
Install the Required Libraries:
pip install torch transformers streamlit
-
Load the Model and Tokenizer:
from transformers import MarianMTModel, MarianTokenizer model_name = f'Helsinki-NLP/opus-mt-{src_lang}-{tgt_lang}' model = MarianMTModel.from_pretrained(model_name) tokenizer = MarianTokenizer.from_pretrained(model_name)
-
Translate Text:
text = "Hello, how are you?" translated = model.generate(**tokenizer(text, return_tensors="pt", padding=True)) translated_text = tokenizer.decode(translated[0], skip_special_tokens=True) print(translated_text)
-
Integrate with Streamlit:
- Build a simple UI using Streamlit to take user input and display translations, as shown in the provided
LanguageTranslator.py
file.
- Build a simple UI using Streamlit to take user input and display translations, as shown in the provided
-
Deploy the Application:
- Deploy your application on platforms like Streamlit Sharing, Heroku, or AWS.
Contributions are welcome! If you have any ideas or improvements, feel free to fork the repository and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Developer: [Ahmad Raza]
- LinkedIn: My LinkedIn Profile
- Email: sktfscm21557034@gmail.com
This README.md
provides an overview of the project, instructions for installation and usage, model information, and a guide for others to replicate the project using Hugging Face models. Make sure to update all the placeholder text with your actual information before uploading it to GitHub.