Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
# Basic English-to-Spanish dictionary
|
| 4 |
+
def translate(word):
|
| 5 |
+
dictionary = {
|
| 6 |
+
"dog": "perro",
|
| 7 |
+
"cat": "gato",
|
| 8 |
+
"house": "casa",
|
| 9 |
+
"hello": "hola",
|
| 10 |
+
"goodbye": "adi贸s",
|
| 11 |
+
"thank you": "gracias",
|
| 12 |
+
"please": "por favor",
|
| 13 |
+
"water": "agua",
|
| 14 |
+
"food": "comida",
|
| 15 |
+
"school": "escuela"
|
| 16 |
+
}
|
| 17 |
+
return dictionary.get(word.lower().strip(), "馃攳 Try a different word!")
|
| 18 |
|
| 19 |
+
# Gradio interface
|
| 20 |
+
gr.Interface(
|
| 21 |
+
fn=translate,
|
| 22 |
+
inputs=gr.Textbox(label="Type an English word"),
|
| 23 |
+
outputs=gr.Textbox(label="Spanish Translation"),
|
| 24 |
+
title="馃摎 Spanifyd Flashcard Translator",
|
| 25 |
+
description="Type a word in English to learn the Spanish word. More features coming soon!"
|
| 26 |
+
).launch()
|