Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Import libraries
|
2 |
+
import gradio as gr
|
3 |
+
from gtts import gTTS
|
4 |
+
|
5 |
+
# Simple dictionary for demonstration purposes
|
6 |
+
translation_dict = {
|
7 |
+
"passed": "μ§λκ°λ²λ¦°",
|
8 |
+
"beam": "λΉμ€κΈ°",
|
9 |
+
"electronic": "μ μμ",
|
10 |
+
"fascinate": "λ§μμ μ¬λ‘μ‘λ€, 맀λ£νλ€",
|
11 |
+
"comply": "λ°λ₯΄λ€",
|
12 |
+
"tradition": "μ ν΅",
|
13 |
+
"guard": "μ§ν€λ€, 보νΈνλ€, κ²½λΉλ₯Ό 보λ€",
|
14 |
+
"peak": "μ μ , μ μ , μ΅κ³ μ‘°, κΌλκΈ°",
|
15 |
+
"maintenance": "μ μ§, μνλΉ, μ§μ",
|
16 |
+
"harbor": "νꡬ, νλ§",
|
17 |
+
"condition": "μν, 쑰건",
|
18 |
+
"storm": "νν, νν",
|
19 |
+
"edged": "λ μ΄ μλ, κ°μ₯μλ¦¬κ° μλ",
|
20 |
+
"decide": "κ²°μ νλ€",
|
21 |
+
"elderly": "μ°μΈκ° λμ , λμ΄κ° λ ",
|
22 |
+
"realize": "κΉ¨λ«λ€, μμ차리λ€, μΈμνλ€",
|
23 |
+
"modern": "νλμ μΈ",
|
24 |
+
"grave": "무λ€, λ¬",
|
25 |
+
"generation": "μΈλ",
|
26 |
+
"cheaper": "λ μΌ, λ μ λ ΄ν",
|
27 |
+
"technology": "κΈ°μ ",
|
28 |
+
"fail": "μ€ν¨νλ€",
|
29 |
+
"proving": "κ²μ¦νλ€, μ
μ¦νλ€",
|
30 |
+
"require": "μꡬνλ€, νμνλ€, μμ²νλ€",
|
31 |
+
"climb": "μ€λ₯΄λ€, λ±λ°νλ€",
|
32 |
+
"stood": "standμ κ³Όκ±° λΆμ¬, μλ€, μΌμ΄μλ€",
|
33 |
+
"council": "μν",
|
34 |
+
"position": "μμΉ, μ리, λ°°μΉνλ€",
|
35 |
+
"navigation": "νν΄, μ΄ν",
|
36 |
+
"operation": "μλ, κ°λ, μ‘°μ",
|
37 |
+
"happen": "(μ¬κ±΄ λ±μ΄) μΌμ΄λλ€",
|
38 |
+
"lighthouse": "λ±λ",
|
39 |
+
"lantern": "μμ λ±, λν΄",
|
40 |
+
"vast": "μ΄λ§μ΄λ§ν, λ°©λν, λ§λν",
|
41 |
+
"relief": "μλ, μλκ°",
|
42 |
+
"importance": "μ€μμ±",
|
43 |
+
"grandson": "μμ, μΈμμ",
|
44 |
+
"fierce": "μ¬λμ΄, κ²©λ ¬ν, κ·Ήμ¬ν",
|
45 |
+
"panic": "κ·Ήμ¬ν 곡ν¬, κ²μ μ§λ € μ΄μ© μ€ λͺ¨λ₯΄λ€",
|
46 |
+
"proposed": "μ μλ",
|
47 |
+
"mariner": "μ μ, λ±μ¬λ",
|
48 |
+
"ensure": "λ°λμ ~νκ² νλ€, 보μ₯νλ€",
|
49 |
+
"responsibly": "μ±
μκ° μκ²",
|
50 |
+
"flickering": "κΉλ°κ±°λ¦¬λ, κΊΌμ§ κ² κ°μ, μ½ν",
|
51 |
+
"cliff": "μ λ²½",
|
52 |
+
"humble": "κ²Έμν, κ²Έννκ² λ§λ€λ€",
|
53 |
+
"severe": "κ·Ήμ¬ν, κ°νΉν, μν",
|
54 |
+
"efficiency": "ν¨μ¨, ν¨μ¨ν",
|
55 |
+
"familiar": "μ΅μν",
|
56 |
+
"guiding": "μΈλνλ, μλ΄νλ",
|
57 |
+
"jagged": "μμμμν, λ€μ₯λ μ₯ν",
|
58 |
+
"decision": "κ²°μ , κ²°λ¨λ ₯",
|
59 |
+
"disastrous": "μ²μ°Έν, ννΈμλ",
|
60 |
+
"heartbroken": "λΉν΅ν΄ νλ, μ¬νμ μ κΈ΄, λΉνμ μ μ",
|
61 |
+
"wisdom": "μ§ν",
|
62 |
+
"solution": "ν΄κ²°μ±
",
|
63 |
+
"miraculously": "κΈ°μ μ μΌλ‘",
|
64 |
+
"rush": "κΈν μμ§μ΄λ€, νΌμ‘, μΉλ°μ΄ μ€λ₯΄λ€",
|
65 |
+
"brewed": "λͺ°μμΉλ€",
|
66 |
+
"reinstated": "볡μ§νλ€, 볡κ·νλ€",
|
67 |
+
"enduring": "μ€λκ°λ",
|
68 |
+
"winding": "ꡬλΆκ΅¬λΆν",
|
69 |
+
"unthinkable": "μμλ ν μ μλ"
|
70 |
+
}
|
71 |
+
|
72 |
+
# Define the translation and text-to-speech function
|
73 |
+
def translate_and_speak(word):
|
74 |
+
korean_translation = translation_dict.get(word.lower(), "Translation not found")
|
75 |
+
tts = gTTS(korean_translation, lang='ko')
|
76 |
+
tts.save("translation.mp3")
|
77 |
+
return korean_translation, "translation.mp3"
|
78 |
+
|
79 |
+
# Create the Gradio interface
|
80 |
+
interface = gr.Interface(
|
81 |
+
fn=translate_and_speak,
|
82 |
+
inputs=gr.Textbox(lines=1, placeholder="Enter English word here..."),
|
83 |
+
outputs=[gr.Textbox(label="Korean Translation"), gr.Audio(label="Pronunciation")],
|
84 |
+
title="English to Korean Translator",
|
85 |
+
description="Enter an English word to get its meaning in Korean and listen to the pronunciation."
|
86 |
+
)
|
87 |
+
|
88 |
+
# Launch the interface
|
89 |
+
interface.launch()
|