Spaces:
Sleeping
Sleeping
# 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() |