Spaces:
Sleeping
Sleeping
File size: 3,497 Bytes
868e124 a77cd97 868e124 a77cd97 4a14318 a77cd97 4a14318 a77cd97 4a14318 a77cd97 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
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(word, lang='en') # Set lang to 'en' for English pronunciation
tts.save("translation.mp3")
return korean_translation, "translation.mp3"
# Create the Gradio interface with a dropdown
interface = gr.Interface(
fn=translate_and_speak,
inputs=gr.Dropdown(choices=list(translation_dict.keys()), label="Select an English word"),
outputs=[gr.Textbox(label="Korean Translation"), gr.Audio(label="Pronunciation")],
title="English to Korean Translator",
description="Select an English word to get its meaning in Korean and listen to the pronunciation."
)
# Launch the interface
interface.launch() |