File size: 545 Bytes
84cec7f
1855ed6
8b419c8
1855ed6
 
 
 
 
 
8b419c8
1855ed6
 
14e381d
1855ed6
 
 
8b419c8
 
1855ed6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from googletrans import Translator
import gradio as gr

def translate(text):
    translator = Translator()
    result = translator.translate(text, dest='en')
    translation = result.text
    pronunciation = translator.translate(translation, dest='ja').pronunciation
    return f"Pronunciation: {pronunciation}", f"Translation: {translation}"

iface = gr.Interface(
    fn=translate,
    inputs="text",
    outputs=["text", "text"],
    output_labels=["Pronunciation", "Translation"],
    title="Japanese to English Translator"
)

iface.launch()