Jayahae commited on
Commit
4a14318
β€’
1 Parent(s): 868e124

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -75
app.py CHANGED
@@ -1,75 +1,3 @@
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
- # Import libraries
73
  import gradio as gr
74
  from gtts import gTTS
75
 
@@ -147,13 +75,13 @@ def translate_and_speak(word):
147
  tts.save("translation.mp3")
148
  return korean_translation, "translation.mp3"
149
 
150
- # Create the Gradio interface
151
  interface = gr.Interface(
152
  fn=translate_and_speak,
153
- inputs=gr.Textbox(lines=1, placeholder="Enter English word here..."),
154
  outputs=[gr.Textbox(label="Korean Translation"), gr.Audio(label="Pronunciation")],
155
  title="English to Korean Translator",
156
- description="Enter an English word to get its meaning in Korean and listen to the pronunciation."
157
  )
158
 
159
  # Launch the interface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from gtts import gTTS
3
 
 
75
  tts.save("translation.mp3")
76
  return korean_translation, "translation.mp3"
77
 
78
+ # Create the Gradio interface with a dropdown
79
  interface = gr.Interface(
80
  fn=translate_and_speak,
81
+ inputs=gr.Dropdown(choices=list(translation_dict.keys()), label="Select an English word"),
82
  outputs=[gr.Textbox(label="Korean Translation"), gr.Audio(label="Pronunciation")],
83
  title="English to Korean Translator",
84
+ description="Select an English word to get its meaning in Korean and listen to the pronunciation."
85
  )
86
 
87
  # Launch the interface