This repository contains a simple web application built with Flask that utilizes a pre-trained neural translation model to translate English sentences into Hindi.
- Pre-trained Model: The application leverages the
Helsinki-NLP/opus-mt-en-hi
model, a powerful translation model trained on a large dataset of English-Hindi parallel text. - Flask Web App: A Flask web app provides a user-friendly interface for inputting English sentences and receiving Hindi translations.
- Error Handling: The app includes error handling to prevent crashes and display informative messages to the user.
└── English-to-Hindi Neural Translation Model
├── TEMPLATES
│ └── index.html
└── app.py
-
Install Dependencies: Make sure you have Python 3.x installed and the required libraries. You can install them using:
pip install -r requirements.txt
-
Run the App: Execute the following command:
python app.py
-
Access the App: Open your web browser and navigate to
http://127.0.0.1:5000/
(or the address displayed in your terminal).
- Enter an English sentence in the text box on the web page.
- Click the "Translate" button.
- The translated Hindi sentence will be displayed below the input box.
- You can customize the translation model by replacing
Helsinki-NLP/opus-mt-en-hi
with another suitable model from Hugging Face. - Modify the
max_length
parameter in thetranslate_sentence()
function to adjust the maximum length of the translated sentences. - Feel free to enhance the web app's interface and functionality.
- The model's performance might vary depending on the complexity and domain of the input text.
- For optimal results, consider fine-tuning the model on a domain-specific dataset.
- This project serves as a basic example for demonstrating neural machine translation. Further improvements and feature additions are encouraged.
Contributions are welcome! Feel free to fork this repository and submit pull requests for enhancements and bug fixes.