Spaces:
Build error
Build error
Download app.py from rgbguy101/LanguageTranslator: direct link, hf CLI and curl.
- Browser
- Download file 588 Bytes
-
https://huggingface.co/spaces/rgbguy101/LanguageTranslator/resolve/main/app.py
- Command line
-
hf download hf://spaces/rgbguy101/LanguageTranslator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rgbguy101/LanguageTranslator/resolve/main/app.py
588 Bytes
| import gradio as gr | |
| from transformers import pipeline | |
| # Load English to Hindi translation model | |
| translation_pipeline = pipeline("translation_en_to_hi", model="Helsinki-NLP/opus-mt-en-hi") | |
| def translate_text(text): | |
| # Use the pipeline to translate the text | |
| translation = translation_pipeline(text) | |
| # Return the translated text | |
| return translation[0]["translation_text"] | |
| demo = gr.Interface( | |
| fn=translate_text, | |
| inputs="text", | |
| outputs="text", | |
| title="English to Hindi Translator", | |
| description="Enter English text to translate it to Hindi" | |
| ) | |
| demo.launch() |