|
import gradio as gr |
|
import util |
|
import tts |
|
import asr |
|
|
|
|
|
with gr.Blocks() as app: |
|
|
|
with gr.Row(): |
|
gr.Markdown( |
|
""" |
|
<h1 style="text-align: center; font-size: 28px; color: #4A90E2;"> |
|
Uyghur Pronunciation Checker |
|
</h1> |
|
<p style="text-align: center; font-size: 16px; color: #555;"> |
|
This app is designed to help users practice Uyghur pronunciation. |
|
</p> |
|
|
|
Select an input script, enter or generate text, and check your pronunciation. You may also generate AI pronunciation to compare. |
|
|
|
(Note: Please keep the audio input to under 10 seconds for faster processing since this space is running on CPU basic.) |
|
|
|
To learn more about Uyghur speech technology, please check out my [blog post](https://ixxan.github.io/low-resource-speech-ug/) and this other [demo](https://huggingface.co/spaces/ixxan/uyghur-speech-models). |
|
""" |
|
) |
|
with gr.Row(): |
|
|
|
with gr.Column(scale=1): |
|
|
|
with gr.Row(): |
|
script_choice = gr.Dropdown( |
|
choices=["Uyghur Arabic", "Uyghur Latin"], |
|
label="1. Select Uyghur Script", |
|
value="Uyghur Arabic", |
|
interactive=True |
|
) |
|
|
|
with gr.Group(): |
|
with gr.Row(): |
|
input_text = gr.Textbox( |
|
label="2. Enter Uyghur Text in Chosen Script (or Click a Button Below to Generate Text)", |
|
placeholder="Enter Uyghur text here...", |
|
) |
|
with gr.Row(): |
|
generate_short_btn = gr.Button("Generate Short Text") |
|
generate_long_btn = gr.Button("Generate Long Text") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with gr.Group(): |
|
with gr.Row(): |
|
example_audio = gr.Audio(label="(OPTIONAL) Generate AI Pronunciation") |
|
with gr.Row(): |
|
tts_btn = gr.Button("Generate AI Pronunciation") |
|
|
|
with gr.Group(): |
|
with gr.Row(): |
|
user_audio = gr.Audio( |
|
label="3. Record or Upload Your Pronunciation", |
|
sources=["microphone", "upload"], |
|
type="filepath", |
|
) |
|
with gr.Row(): |
|
check_btn = gr.Button("Check My Pronunciation") |
|
|
|
|
|
with gr.Column(scale=1): |
|
|
|
with gr.Group(): |
|
with gr.Row(): |
|
transcript_ugArab_box = gr.Textbox( |
|
label="Your Pronunciation Transcript (Arabic Script)", |
|
placeholder="ASR transcription of user audio..." |
|
) |
|
with gr.Row(): |
|
transcript_ugLatn_box = gr.Textbox( |
|
label="Your Pronunciation Transcript (Latin Script)", |
|
placeholder="ASR transcription of user audio..." |
|
) |
|
|
|
with gr.Group(): |
|
with gr.Row(): |
|
correct_phoneme_box = gr.Textbox( |
|
label="Correct Phonemes", |
|
placeholder="IPA representation of the Correct pronunciation..." |
|
) |
|
with gr.Row(): |
|
user_phoneme_box = gr.Textbox( |
|
label="Your Phonemes", |
|
placeholder="IPA representation of the user pronunciation..." |
|
) |
|
|
|
with gr.Group(): |
|
with gr.Row(): |
|
match_box = gr.Markdown( |
|
"""<h4>Pronunciation Feedback</h4>\n |
|
Matching and mismatched characters will be visualized here... |
|
""" |
|
) |
|
with gr.Row(): |
|
score_box = gr.Textbox( |
|
label="Phonetic Score", |
|
placeholder="Your pronunciation score as a percentage..." |
|
) |
|
|
|
|
|
generate_short_btn.click( |
|
util.generate_short_text, |
|
inputs=[script_choice], |
|
outputs=[input_text] |
|
) |
|
|
|
generate_long_btn.click( |
|
util.generate_long_text, |
|
inputs=[script_choice], |
|
outputs=[input_text] |
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tts_btn.click( |
|
tts.generate_audio, |
|
inputs=[input_text, script_choice], |
|
outputs=[example_audio] |
|
) |
|
|
|
check_btn.click( |
|
asr.check_pronunciation, |
|
inputs=[input_text, script_choice, user_audio], |
|
outputs=[transcript_ugArab_box, transcript_ugLatn_box, correct_phoneme_box, user_phoneme_box, match_box, score_box] |
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
app.queue(default_concurrency_limit = 2, max_size=20) |
|
app.launch() |