File size: 4,502 Bytes
06eca01
 
b8172f2
06eca01
 
d5354f5
 
0dcb21c
06eca01
5af8dc3
06eca01
 
 
 
 
016c990
d5354f5
d8834a7
06eca01
 
b8172f2
fc436cf
 
b8172f2
06eca01
 
 
 
 
0dcb21c
26f695c
 
 
 
 
 
 
 
 
337d743
26f695c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28c0978
0b808c1
d196921
 
df5b3e3
8d8a9b2
69d94dc
 
 
0b808c1
 
 
 
 
21bdd6b
 
d5354f5
06eca01
97ed172
 
61e255a
97ed172
61e255a
97ed172
0b808c1
21bdd6b
 
d5354f5
06eca01
97ed172
 
 
016c990
 
b8172f2
06eca01
 
 
5f40629
06eca01
 
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
import gradio as gr
import vowel_length
import ctcalign


meta_tsv = ['data/set1.tsv','data/set2.tsv']
ph_key = 'data/key_all.tsv'
align_output = 'data/align_csv.pickle'

dat,vck,kws,csvs = vowel_length.setup(meta_tsv,ph_key,align_output)

#    runan(w,'l1','w2v2',vck,dat,sources)
#    runan(w,'l1','mfa',vck,dat,sources)


def manager(word,group,aligner,side):
    fig = vowel_length.runan(word,group,aligner,vck,dat,csvs) #TODO add colour by plot-side
    print(side)
    return fig

def aligning(transcript, audio, language):
    formatted_output = ctcalign.langsalign(audio,transcript,language)
    return formatted_output


bl = gr.Blocks()
with bl:


    with gr.Tabs():

        with gr.TabItem("CTC alignment"):
            gr.Markdown(
            """
            # Forced alignment with CTC decoding
            Choose a language to upload a sentence with corresponding text. Generate word and letter time-alignments from the language's wav2vec-2.0 model, with output in MFA (Montreal Forced Aligner)-compatible format. It is best to upload short recordings of a sentence or so; recordings over a couple minutes require excessive memory to align, and should be divided into shorter pieces. Use only lower case letters with no punctuation.
            """
                 )

            gr.Markdown(
            """
            Contact [email protected] with feedback, problems, and to request changes.
            """
                 )

            with gr.Row():
                with gr.Column():
                    transcript_boxx = gr.Textbox(label="Transcript",placeholder="Type or paste the transcript here. Capitalisation and punctuation, if any, will be ignored.")

                    audio_file = gr.Audio(type="filepath")

                    alangmenu = gr.Radio(["Icelandic", "Faroese", "Norwegian"],value="Icelandic",label="Language")

                    al_btn = gr.Button(value="Run forced alignment")

                with gr.Column():
                    output_box = gr.Textbox(label="Forced alignment output")

                al_btn.click(aligning, [transcript_boxx, audio_file, alangmenu], output_box)

        
        with gr.TabItem("Vowel quantity"):
            gr.Markdown(
            """ 
# Long and short Icelandic vowels 
Choose a word, speaker group, and aligner type. Available speaker groups are native speakers, second-language speakers, or all. Aligner options are Montreal Forced Aligner (MFA) and CTC decoding with Wav2vec-2.0. If the graph shows "Error" this means there is not data for the selected word, speaker group, and alignment type. 

The general expectation is that syllables with long stressed vowels followed by short consonants have a higher vowel:consonant duration ratio, while syllables with short stressed vowels followed by long consonants have a lower vowel:consonant ratio. However, a great many other factors affect the relative duration in any one recorded token. See Pind 1999, 'Speech segment durations and quantity in Icelandic' (J. Acoustical Society of America, 106(2)) for a review of the acoustics of Icelandic vowel duration. 

All phoneme durations are measured automatically with no human correction. The purpose of this demo is to evaluate the role of such tools in large-scale phonetic research. Therefore, no measurements shown in this demo should be taken as conclusive without some independent verification. 
            """
                )

            with gr.Row():
                with gr.Column():
                    wmenu1 = gr.Dropdown(kws,label="Word",value="hala")
                    lmenu1 = gr.Dropdown(["L1", "L2","All"],label="Speaker group",value="L1")
                    amenu1 = gr.Dropdown(["MFA", "CTC"],label="Aligner",value="CTC")
    
                    btn1 = gr.Button(value="Update Plot 1")
                
                    pl1 = gr.Plot()
                    btn1.click(manager, [wmenu1, lmenu1, amenu1, btn1], pl1)
                                

                with gr.Column():
                    wmenu2 = gr.Dropdown(kws,label="Word",value="halla")
                    lmenu2 = gr.Dropdown(["L1", "L2","All"],label="Speaker group",value="L1")
                    amenu2 = gr.Dropdown(["MFA", "CTC"],label="Aligner",value="CTC")
    
                    btn2 = gr.Button(value="Update Plot 2")
                    pl2 = gr.Plot()
                    btn2.click(manager, [wmenu2, lmenu2, amenu2, btn2], pl2)

            



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