| import gradio as gr |
| import subprocess |
|
|
| def pronounce(word): |
|
|
| if not word.strip(): |
| return None |
|
|
| filename = "voice.mp3" |
|
|
| subprocess.run([ |
| "edge-tts", |
| "--text", |
| word, |
| "--write-media", |
| filename, |
| "--voice", |
| "ru-RU-DmitryNeural" |
| ]) |
|
|
| return filename |
|
|
| with gr.Blocks() as demo: |
|
|
| gr.Markdown("# 🔊 Phát âm tiếng Nga") |
|
|
| word_input = gr.Textbox( |
| label="Nhập từ tiếng Nga" |
| ) |
|
|
| audio_output = gr.Audio( |
| type="filepath", |
| autoplay=True |
| ) |
|
|
| btn = gr.Button("🔊 Pronounce") |
|
|
| btn.click( |
| pronounce, |
| inputs=word_input, |
| outputs=audio_output, |
| queue=False |
| ) |
|
|
| demo.launch( |
| show_error=True |
| ) |