File size: 6,024 Bytes
7dbde5a 734a7ea ce63f6f d29fa84 5a4ac64 734a7ea 79353f4 334daaa b317d81 96bfe7a b317d81 334daaa 7a05dac 96bfe7a b317d81 5c2f6e1 334daaa 5a4ac64 8e57d14 5a4ac64 be00192 c510f60 be00192 8e57d14 43ce49e c510f60 43ce49e 8e57d14 b80e2d5 8e57d14 43ce49e 739808f 43ce49e fe67771 8e57d14 43ce49e 8e57d14 43ce49e 5a4ac64 8e57d14 b1e229a 0e8c610 0adf640 d6d3fa1 0e8c610 0adf640 d6d3fa1 0e8c610 8e57d14 b1e229a 0e8c610 fe67771 0e8c610 fe67771 0adf640 d6d3fa1 0e8c610 8e57d14 b1e229a aab3ee4 ff91a06 b8881c6 aab3ee4 8e57d14 5a4ac64 716237b 734a7ea deb8ef3 ea0e1cd 716237b deb8ef3 716237b 734a7ea deb8ef3 ea0e1cd 716237b 8e57d14 ec77e62 716237b d29fa84 5a4ac64 d29fa84 5a4ac64 fe67771 5a4ac64 734a7ea 5a4ac64 739808f e97ae37 |
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
import gradio as gr
import util
import tts
import asr
# Front-End
with gr.Blocks() as app:
# Title and Article
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():
# Input Column
with gr.Column(scale=1):
# Script
with gr.Row():
script_choice = gr.Dropdown(
choices=["Uyghur Arabic", "Uyghur Latin"],
label="1. Select Uyghur Script",
value="Uyghur Arabic",
interactive=True
)
# Text
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")
# Translations
# with gr.Group():
# with gr.Row():
# translate_choice = gr.Dropdown(
# choices=util.translation_choices,
# label="(Optional) Select Translation Langauge and Translate",
# value="english",
# interactive=True
# )
# translate_btn = gr.Button("Translate")
# with gr.Row():
# translation_text = gr.Textbox(
# label=" Translated Uyghur Text",
# placeholder="Translated text will appear here...",
# )
# TTS
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")
# ASR
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")
# Output Column
with gr.Column(scale=1):
# ASR Transcripts
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..."
)
# IPA
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..."
)
# Feedback
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..."
)
# Bind functions to buttons
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]
)
# translate_btn.click(
# util.translate_text,
# inputs=[input_text, script_choice, translate_choice],
# outputs=[translation_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]
)
# Main
if __name__ == "__main__":
app.queue(default_concurrency_limit = 2, max_size=20) # <-- Sets up a queue with default parameters
app.launch() |