Spaces:
Sleeping
Sleeping
File size: 7,184 Bytes
1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc ecd5f69 1e483fc |
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 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
import gradio as gr
import vowel_length as vln
annotation_json = 'Data/Length_in_spoken_icelandic.json'
menus, vdata = vln.setup(annotation_json)
grouplist = [g for g,ws in menus]
worddict = {g:ws for g,ws in menus}
def get_group_words(group):
if group == '[NONE]':
choices = ['[NONE]']
else:
choices = [ '[ALL]' ] + [n for n,v in worddict[group]]
return gr.Dropdown(choices = choices, value = choices[0], interactive=True)
def check_word_langs(word,cur_lang):
if ' [L' not in word:
return gr.Radio(value=cur_lang,interactive=True)
elif ' [L1]' in word:
return gr.Radio(value='L1',interactive=False)
else:
return gr.Radio(value='L2',interactive=False)
def subset_words_spks(g,w,l,s,wsets,db):
if w == '[ALL]':
swords = [v for n,v in wsets[g]]
labl = g
else:
labl = w.split(' ')[0]
swords = [labl]
if l == 'All':
slang = ['L1', 'L2']
labl += f'\n L1+L2, '
else:
slang = [l]
labl += f'\n {l}, '
labl += f'{s}'
db1 = db.copy()
db1 = db1.loc[ (db1['speaker_lang'].isin(slang)) & (db1['word'].isin(swords)) ]
db1.reset_index()
if s.lower() == 'mfa':
src = 'mfa'
else:
assert s[:3].lower() == 'ann'
src = 'gold'
return db1, src, labl
def plott(g1,w1,l1,s1,g2,w2,l2,s2):
dat1,src1,lab1 = subset_words_spks(g1,w1,l1,s1,worddict,vdata)
if '[NONE]' in [g2, w2]:
dat2, l2, src2, lab2 = None, None, None, None
else:
dat2,src2,lab2 = subset_words_spks(g2,w2,l2,s2,worddict,vdata)
fig = vln.vgraph(dat1,l1,src1,lab1,dat2,l2,src2,lab2)
return fig
bl = gr.Blocks()#theme=gr.themes.Glass())
with bl:
with gr.Tabs():
with gr.TabItem("Vowel quantity"):
with gr.Row():
with gr.Column():
gr.Markdown(
"""
#### Select data (1)
"""
)
gmenu1 = gr.Dropdown(choices=grouplist,label="Group", value='AL:')
wmenu1 = gr.Dropdown(label="Word", choices=['[ALL]'] + [n for n,v in worddict['AL:']])
lmenu1 = gr.Radio(["L1", "L2","All"],label="Speaker group",value="L1")
smenu1 = gr.Dropdown(["Annotated", "MFA"],label="Source",value="Annotated")
gmenu1.change(get_group_words,inputs=[gmenu1],outputs = [wmenu1])
wmenu1.input(check_word_langs,inputs=[wmenu1,lmenu1],outputs = [lmenu1])
with gr.Column():
gr.Markdown(
"""
#### Select data (2)
"""
)
gmenu2 = gr.Dropdown(choices=['[NONE]'] + grouplist,label="Group", value='A:L')
wmenu2 = gr.Dropdown(label="Word", choices=['[ALL]'] + [n for n,v in worddict['A:L']])
lmenu2 = gr.Radio(choices=["L1", "L2","All"],label="Speaker group",value="L1")
smenu2 = gr.Dropdown(["Annotated", "MFA"],label="Source",value="Annotated")
gmenu2.change(get_group_words,inputs=[gmenu2],outputs = [wmenu2])
wmenu2.input(check_word_langs,inputs=[wmenu2,lmenu2],outputs = [lmenu2])
btn = gr.Button(value="Update Plot")
plo = gr.Plot(value=plott('AL:','[ALL]',"L1","Annotated",'A:L','[ALL]',"L1","Annotated"))
btn.click(plott, [gmenu1,wmenu1,lmenu1,smenu1,gmenu2,wmenu2,lmenu2,smenu2], plo)
gr.Markdown(
"""
# Long and short Icelandic vowels
Check the About tab for more info about the project.
"""
)
with gr.TabItem("About"):
gr.Markdown(
"""
## Assessed and Annotated Vowel Lengths in Spoken Icelandic Sentences\
for L1 and L2 Speakers: A Resource for Pronunciation Training
"""
)
gr.Markdown(
"""
### About
This annotated data and its demo application accompany the paper
*Assessed and Annotated Vowel Lengths in Spoken Icelandic Sentences\
for L1 and L2 Speakers: A Resource for Pronunciation Training*, \
Caitlin Laura Richter, Kolbr煤n Fri冒riksd贸ttir, Korm谩kur Logi Bergsson, \
Erik Anders Maher, Ragnhei冒ur Mar铆a Benediktsd贸ttir, Jon Gudnason - NoDaLiDa/Baltic-HLT 2025, Tallinn, Estonia.
"""
)
gr.Markdown(
"""
## Demo: Viewing the data
Use the menus to choose words, speaker group, and data source.
Words are split into related groups and either the whole group or a single word can be selected.
Available speaker groups are native Icelandic speakers (L1), second-language speakers (L2), or all.
Data source options are gold (human) annotations or automated Montreal Forced Aligner (MFA).
The display is a scatter plot of vowel and consonant durations,
supplemented with density plots for each dimension separately.
The general expectation is that, all else being equal, syllables with long stressed vowels
followed by short consonants have a higher vowel:(vowel+consonant) duration ratio,
while syllables with short stressed vowels followed by long consonants have a lower ratio.
Many other factors also affect relative durations in any particular recorded token,
and these factors have considerable - not necessarily balanced - variation throughout this dataset.
This demo is provided to begin exploring the data and suggest hypotheses for follow-up.
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.
"""
)
gr.Markdown(
"""
## Accessing the data
Annotations can be downloaded as
[json](https://github.com/catiR/length-contrast-data-isl/blob/main/Data/Length_in_spoken_icelandic.json)
or [tsv](https://github.com/catiR/length-contrast-data-isl/blob/main/Data/Length_in_spoken_icelandic.tsv) files.
See [the paper](https://github.com/catiR/length-contrast-data-isl/blob/main/Data/133_Annotated_Vowel_Lengths.pdf)
for complete information.
"""
)
gr.Markdown(
"""
Audio is available from [Clarin](https://repository.clarin.is/repository/xmlui/) (Samr贸mur).
The 'collection' field plus recording filename in the annotations metadata
specify the original audio file, including which Samr贸mur collection it is found in.
"""
)
gr.Markdown(
"""
Annotation records are in the following scheme:
```
[ { recording: source-file-id.wav,
collection: samromur-collection,
speaker_lang: L1/L2,
word: target-word,
word_context: {
normalised: normalised-carrier-sentence-text,
before: sentence-context-preceding-token,
after: sentence-context-following-token
},
gold_annotation: {
target_word_start: seconds,
target_word_end: seconds,
prevowel: [ {
phone: ipa-character,
start: seconds,
end: seconds,
},
{ phone2 ... } ,
],
vowel: [ {
phone: ipa-character,
start: seconds,
end: seconds,
},
],
postvowel: [ {
phone: ipa-character,
start: seconds,
end: seconds,
},
]
},
mfa_annotation : {
... as for gold ...
}
},
]
```
"""
)
gr.Markdown(
"""
### Contact [email protected] about bugs, feedback, or collaboration!
"""
)
if __name__ == "__main__":
bl.launch()
|