Gradio_Meaning / app.py
Jayahae's picture
Create app.py
a77cd97 verified
raw
history blame
3.45 kB
# Import libraries
import gradio as gr
from gtts import gTTS
# Simple dictionary for demonstration purposes
translation_dict = {
"passed": "μ§€λ‚˜κ°€λ²„λ¦°",
"beam": "빛쀄기",
"electronic": "μ „μžμ˜",
"fascinate": "λ§ˆμŒμ„ μ‚¬λ‘œμž‘λ‹€, λ§€λ£Œν•˜λ‹€",
"comply": "λ”°λ₯΄λ‹€",
"tradition": "전톡",
"guard": "지킀닀, λ³΄ν˜Έν•˜λ‹€, κ²½λΉ„λ₯Ό 보닀",
"peak": "μ ˆμ •, 정점, 졜고쑰, κΌ­λŒ€κΈ°",
"maintenance": "μœ μ§€, μƒν™œλΉ„, 지속",
"harbor": "항ꡬ, ν•­λ§Œ",
"condition": "μƒνƒœ, 쑰건",
"storm": "폭풍, νƒœν’",
"edged": "날이 μžˆλŠ”, κ°€μž₯μžλ¦¬κ°€ μžˆλŠ”",
"decide": "κ²°μ •ν•˜λ‹€",
"elderly": "μ—°μ„Έκ°€ λ“œμ‹ , λ‚˜μ΄κ°€ λ“ ",
"realize": "κΉ¨λ‹«λ‹€, μ•Œμ•„μ°¨λ¦¬λ‹€, μΈμ‹ν•˜λ‹€",
"modern": "ν˜„λŒ€μ μΈ",
"grave": "무덀, 묘",
"generation": "μ„ΈλŒ€",
"cheaper": "더 μ‹Ό, 더 μ €λ ΄ν•œ",
"technology": "기술",
"fail": "μ‹€νŒ¨ν•˜λ‹€",
"proving": "κ²€μ¦ν•˜λ‹€, μž…μ¦ν•˜λ‹€",
"require": "μš”κ΅¬ν•˜λ‹€, ν•„μš”ν•˜λ‹€, μš”μ²­ν•˜λ‹€",
"climb": "였λ₯΄λ‹€, λ“±λ°˜ν•˜λ‹€",
"stood": "stand의 κ³Όκ±° 뢄사, μ„œλ‹€, μΌμ–΄μ„œλ‹€",
"council": "의회",
"position": "μœ„μΉ˜, 자리, λ°°μΉ˜ν•˜λ‹€",
"navigation": "ν•­ν•΄, μš΄ν•­",
"operation": "μž‘λ™, 가동, μ‘°μž‘",
"happen": "(사건 등이) μΌμ–΄λ‚˜λ‹€",
"lighthouse": "λ“±λŒ€",
"lantern": "손전등, λžœν„΄",
"vast": "μ–΄λ§ˆμ–΄λ§ˆν•œ, λ°©λŒ€ν•œ, λ§‰λŒ€ν•œ",
"relief": "μ•ˆλ„, μ•ˆλ„κ°",
"importance": "μ€‘μš”μ„±",
"grandson": "μ†μž, μ™Έμ†μž",
"fierce": "μ‚¬λ‚˜μš΄, κ²©λ ¬ν•œ, κ·Ήμ‹¬ν•œ",
"panic": "κ·Ήμ‹¬ν•œ 곡포, 겁에 질렀 μ–΄μ©” 쀄 λͺ¨λ₯΄λ‹€",
"proposed": "μ œμ•ˆλœ",
"mariner": "선원, λ±ƒμ‚¬λžŒ",
"ensure": "λ°˜λ“œμ‹œ ~ν•˜κ²Œ ν•˜λ‹€, 보μž₯ν•˜λ‹€",
"responsibly": "μ±…μž„κ° 있게",
"flickering": "κΉœλ°•κ±°λ¦¬λŠ”, 꺼질 것 같은, μ•½ν•œ",
"cliff": "절벽",
"humble": "κ²Έμ†ν•œ, κ²Έν—ˆν•˜κ²Œ λ§Œλ“€λ‹€",
"severe": "κ·Ήμ‹¬ν•œ, κ°€ν˜Ήν•œ, μ—„ν•œ",
"efficiency": "효율, νš¨μœ¨ν™”",
"familiar": "μ΅μˆ™ν•œ",
"guiding": "μΈλ„ν•˜λŠ”, μ•ˆλ‚΄ν•˜λŠ”",
"jagged": "μ‚μ­‰μ‚μ­‰ν•œ, λ“€μ‘₯λ‚ μ‘₯ν•œ",
"decision": "κ²°μ •, 결단λ ₯",
"disastrous": "μ²˜μ°Έν•œ, ν˜•νŽΈμ—†λŠ”",
"heartbroken": "비톡해 ν•˜λŠ”, μŠ¬ν””μ— 잠긴, 비탄에 젖은",
"wisdom": "μ§€ν˜œ",
"solution": "ν•΄κ²°μ±…",
"miraculously": "기적적으둜",
"rush": "κΈ‰νžˆ 움직이닀, 혼작, μΉ˜λ°€μ–΄ 였λ₯΄λ‹€",
"brewed": "λͺ°μ•„μΉ˜λ‹€",
"reinstated": "λ³΅μ§ν•˜λ‹€, λ³΅κ·€ν•˜λ‹€",
"enduring": "μ˜€λž˜κ°€λŠ”",
"winding": "κ΅¬λΆˆκ΅¬λΆˆν•œ",
"unthinkable": "상상도 ν•  수 μ—†λŠ”"
}
# Define the translation and text-to-speech function
def translate_and_speak(word):
korean_translation = translation_dict.get(word.lower(), "Translation not found")
tts = gTTS(korean_translation, lang='ko')
tts.save("translation.mp3")
return korean_translation, "translation.mp3"
# Create the Gradio interface
interface = gr.Interface(
fn=translate_and_speak,
inputs=gr.Textbox(lines=1, placeholder="Enter English word here..."),
outputs=[gr.Textbox(label="Korean Translation"), gr.Audio(label="Pronunciation")],
title="English to Korean Translator",
description="Enter an English word to get its meaning in Korean and listen to the pronunciation."
)
# Launch the interface
interface.launch()