import gradio as gr import vowel_length tsv = 'data/set1.tsv' ph_key = 'data/key_set1_mfaCapt.tsv' sources = {'w2v2':'data/set1_w2v2/','mfa':'data/set1_mfa/'} dat,vck,kws = vowel_length.setup(tsv,ph_key) kws = ['ala', 'bala', 'dala', 'hala', 'skjala', 'kala', 'mala', 'smala', 'sala', 'tala', 'vala', 'dvala', 'svala', 'alla', 'falla', 'galla', 'halla', 'fjalla', 'hjalla', 'mjalla', 'spjalla', 'kalla', 'skalla', 'lalla', 'malla', 'palla', 'bralla', 'valla', 'baki', 'maki', 'raki', 'taki', 'vaki', 'þaki', 'baggi', 'maggi', 'raggi', 'leki', 'speki', 'reki', 'breki', 'veki', 'eggi', 'beggi', 'skeggi', 'leggi', 'veggi'] # 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,sources) #TODO add colour by plot-side print(side) return fig bl = gr.Blocks() with bl: #with gr.Tabs(): # with gr.TabItem("One"): gr.Markdown( """ # Length of 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. 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. 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. """ ) 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", "w2v2"],label="Aligner",value="w2v2") 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", "w2v2"],label="Aligner",value="w2v2") btn2 = gr.Button(value="Update Plot 2") pl2 = gr.Plot() btn2.click(manager, [wmenu2, lmenu2, amenu2, btn2], pl2) # with gr.TabItem("Two"): # gr.Markdown( # """ # # Forced alignment demo with CTC decoding # Choose a language to record or upload a sentence with text. Generate word or letter time-alignments from the language's wav2vec-2.0 model, with output in MFA (Montreal Forced Aligner)-compatible format. # """ # ) if __name__ == "__main__": bl.launch()