|
import gradio as gr |
|
|
|
def generate_example_pronunciation(input_text, script): |
|
|
|
example_audio = None |
|
return example_audio |
|
|
|
def check_pronunciation(input_text, script, user_audio): |
|
|
|
transcript = "Transcribed text here" |
|
correct_pronunciation = "Correct pronunciation in IPA" |
|
user_pronunciation = "User pronunciation in IPA" |
|
pronunciation_match = "Matching segments in green, mismatched in red" |
|
pronunciation_score = 85.7 |
|
return transcript, correct_pronunciation, user_pronunciation, pronunciation_match, pronunciation_score |
|
|
|
with gr.Blocks() as app: |
|
with gr.Row(): |
|
|
|
with gr.Column(scale=1): |
|
with gr.Row(): |
|
input_text = gr.Textbox( |
|
label="Input Uyghur Text to Pronounce", |
|
placeholder="Enter Uyghur text here...", |
|
) |
|
script_choice = gr.Radio( |
|
choices=["Arabic Script", "Latin Script"], |
|
label="Input Text Script", |
|
value="Arabic Script" |
|
) |
|
with gr.Row(): |
|
example_audio = gr.Audio(label="Example Pronunciation", interactive=False) |
|
generate_btn = gr.Button("Generate Example Pronunciation") |
|
with gr.Row(): |
|
user_audio = gr.Audio( |
|
label="Your Pronunciation", |
|
sources=["microphone", "upload"], |
|
type="filepath", |
|
) |
|
check_btn = gr.Button("Check My Pronunciation") |
|
|
|
|
|
with gr.Column(scale=1): |
|
transcript_box = gr.Textbox( |
|
label="Transcript", |
|
placeholder="Automatic transcription of your audio..." |
|
) |
|
correct_pronunciation_box = gr.Textbox( |
|
label="Correct Pronunciation", |
|
placeholder="IPA representation of the correct pronunciation..." |
|
) |
|
user_pronunciation_box = gr.Textbox( |
|
label="User Pronunciation", |
|
placeholder="IPA representation of your pronunciation..." |
|
) |
|
match_box = gr.Textbox( |
|
label="Pronunciation Match", |
|
placeholder="Matching and mismatched characters visualized here..." |
|
) |
|
score_box = gr.Textbox( |
|
label="Pronunciation Score", |
|
placeholder="Your pronunciation score as a percentage..." |
|
) |
|
|
|
|
|
generate_btn.click( |
|
generate_example_pronunciation, |
|
inputs=[input_text, script_choice], |
|
outputs=[example_audio] |
|
) |
|
|
|
check_btn.click( |
|
check_pronunciation, |
|
inputs=[input_text, script_choice, user_audio], |
|
outputs=[transcript_box, correct_pronunciation_box, user_pronunciation_box, match_box, score_box] |
|
) |
|
|
|
if __name__ == "__main__": |
|
app.launch() |