File size: 4,107 Bytes
7dbde5a
734a7ea
ce63f6f
d29fa84
5a4ac64
734a7ea
5a4ac64
 
 
 
 
be00192
 
 
 
 
 
43ce49e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5a4ac64
 
 
0e8c610
b1e229a
0e8c610
 
2dddc43
d6d3fa1
0e8c610
 
 
2dddc43
d6d3fa1
0e8c610
 
d6d3fa1
b1e229a
0e8c610
d6d3fa1
 
 
0e8c610
 
 
 
d6d3fa1
0e8c610
 
b1e229a
 
 
 
6f2612f
b1e229a
aab3ee4
 
 
 
 
5a4ac64
 
716237b
734a7ea
deb8ef3
ea0e1cd
716237b
deb8ef3
716237b
734a7ea
deb8ef3
ea0e1cd
716237b
 
 
d29fa84
5a4ac64
 
 
 
 
d29fa84
5a4ac64
d6d3fa1
5a4ac64
 
734a7ea
5a4ac64
 
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
import gradio as gr
import util
import tts
import asr

# Front-End
with gr.Blocks() as app:
    with gr.Row():
        # Input Column
        with gr.Column(scale=1):
            with gr.Row():
                script_choice = gr.Dropdown(
                    choices=["Uyghur Arabic", "Uyghur Latin"],
                    label="1. Select Input Script",
                    value="Uyghur Arabic",
                    interactive=True
                )
            with gr.Group():
                with gr.Row():
                    input_text = gr.Textbox(
                        label="2. Input Uyghur Text in Selected Script or Generate Text with Buttons below",
                        placeholder="Enter Uyghur text here...",
                    )
                # Add buttons for generating short and long texts
                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="3. Click \"Generate Machine Pronunciation\"")
                with gr.Row():
                    tts_btn = gr.Button("Generate Machine Pronunciation")
            with gr.Group():
                with gr.Row():
                    user_audio = gr.Audio(
                        label="4. 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):
            # Group transcripts together
            with gr.Group():
                with gr.Row():
                    transcript_ugArab_box = gr.Textbox(
                        label="User Transcript (Uyghur Arabic)",
                        placeholder="ASR transcription of user audio..."
                    )
                with gr.Row():
                    transcript_ugLatn_box = gr.Textbox(
                        label="User Transcript (Uyghur Latin)",
                        placeholder="ASR transcription of user audio..."
                    )
            
            # Group machine and user pronunciation
            with gr.Group():
                with gr.Row():
                    machine_pronunciation_box = gr.Textbox(
                        label="Machine Pronunciation",
                        placeholder="IPA representation of the machine pronunciation..."
                    )
                with gr.Row():
                    user_pronunciation_box = gr.Textbox(
                        label="User Pronunciation",
                        placeholder="IPA representation of the user pronunciation..."
                    )

            with gr.Group():
                with gr.Row():
                    score_box = gr.Textbox(
                        label="Phonetic Score",
                        placeholder="Your pronunciation score as a percentage..."
                    )
                with gr.Row():
                    match_box = gr.Markdown(
                        label="Phonetic Match",
                        value="Matching and mismatched characters visualized here..."
                    )

    # 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]
    )
    
    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, machine_pronunciation_box, user_pronunciation_box, match_box, score_box]
    )

# Main
if __name__ == "__main__":
    app.launch()