Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load AI translation model
|
| 5 |
+
translator = pipeline("translation_en_to_fr", model="Helsinki-NLP/opus-mt-en-fr")
|
| 6 |
+
|
| 7 |
+
# Chatbot function for translation
|
| 8 |
+
def chatbot_translate(message, history):
|
| 9 |
+
translated = translator(message)[0]['translation_text']
|
| 10 |
+
return translated
|
| 11 |
+
|
| 12 |
+
# Create Chatbot UI
|
| 13 |
+
iface = gr.ChatInterface(
|
| 14 |
+
chatbot_translate,
|
| 15 |
+
title="AI Translator Bot",
|
| 16 |
+
description="Chat with me in English, and I'll translate to French instantly!",
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
iface.launch()
|