File size: 4,760 Bytes
7dbde5a
 
5a4ac64
 
 
 
7dbde5a
5a4ac64
 
0e8c610
 
5a4ac64
 
 
 
8556a23
5a4ac64
 
 
 
 
 
be00192
 
 
 
 
 
 
 
 
 
 
5a4ac64
deab4af
0bb57fd
0e8c610
5a4ac64
 
466dd36
5a4ac64
 
 
293f2a1
5a4ac64
 
 
 
0e8c610
b1e229a
0e8c610
 
be00192
 
0e8c610
 
 
be00192
 
0e8c610
 
 
b1e229a
0e8c610
 
 
 
 
 
 
 
 
 
 
b1e229a
 
 
 
 
 
 
 
 
 
 
 
93e9d4f
 
 
 
 
 
 
 
 
 
 
5a4ac64
 
 
 
 
 
 
 
 
 
 
8556a23
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
111
112
113
import gradio as gr

def generate_example_pronunciation(input_text, script):
    # Placeholder for generating example pronunciation
    example_audio = None  # Replace with actual example audio generation logic
    return example_audio

def check_pronunciation(input_text, script, user_audio):
    # Placeholder logic for pronunciation checking
    transcript_ugArab_box = "Automatic transcription of your audio (Arabic)..."
    transcript_ugLatn_box = "Automatic transcription of your audio (Latin)..."
    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  # Replace with actual score calculation
    return transcript_ugArab_box, transcript_ugLatn_box, correct_pronunciation, user_pronunciation, pronunciation_match, pronunciation_score

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.Row():
                input_text = gr.Textbox(
                    label="2. Input Uyghur Text to Pronounce",
                    placeholder="Enter Uyghur text here...",
                )
            with gr.Row():
                example_audio = gr.Audio(label="3. Click \"Generate Example Pronunciation\"")
            with gr.Row():
                generate_btn = gr.Button("Generate Example Pronunciation")
            with gr.Row():
                user_audio = gr.Audio(
                    label="4. Record/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="Transcript (Uyghur Arabic)",
                        placeholder="ASR transcription of your audio..."
                    )
                with gr.Row():
                    transcript_ugLatn_box = gr.Textbox(
                        label="Transcript (Uyghur Latin)",
                        placeholder="ASR transcription of your audio..."
                    )
            
            # Group correct and user pronunciation
            with gr.Group():
                with gr.Row():
                    correct_pronunciation_box = gr.Textbox(
                        label="Correct Pronunciation",
                        placeholder="IPA representation of the correct pronunciation..."
                    )
                with gr.Row():
                    user_pronunciation_box = gr.Textbox(
                        label="User Pronunciation",
                        placeholder="IPA representation of your pronunciation..."
                    )

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

    # Bind functions to buttons
    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_ugArab_box, transcript_ugLatn_box, correct_pronunciation_box, user_pronunciation_box, match_box, score_box]
    )

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