clr commited on
Commit
750e743
·
1 Parent(s): ef74942

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -45,8 +45,7 @@ def pick_lang(langname):
45
  elif langname =="Faroese":
46
  df = datas.ds_f
47
 
48
- dfd = df.data.to_pandas()
49
- dfd = dfd.drop(columns=['audio', 'speaker_id','duration'])
50
  return (df, dfd[:15], "all") #(df, df[:50])
51
 
52
 
@@ -62,14 +61,13 @@ def apply_filters(df,langname,gender):#,ageIS,ageFO):
62
  # filter by dialect
63
 
64
  if gender != "all":
65
- df = df.filter(lambda x: x["gender"].startswith(gender))
66
 
67
  #if age != "all":
68
  # df = df.filter(lambda x: x["age"] == age)
69
 
70
 
71
- dfd = df.data.to_pandas()
72
- dfd = dfd.drop(columns=['audio', 'speaker_id','duration'])
73
  return (df,dfd[:15])
74
 
75
 
@@ -79,15 +77,14 @@ def f1(langname,ds):
79
  elif langname =="Faroese":
80
  lang_aligner = datas.a_f
81
 
82
- maxdat=len(ds)
83
-
84
- ds = ds.select([random.randint(maxdat-1)])
85
- sound_path = ds['audio'][0]['path'] # audio 0 array is the audio data itself
86
- transcript = ds['normalized_text'][0]
87
 
88
- rec_info = f"{ds['audio_id'][0]}, {ds['gender'][0]}, {ds['age'][0]}"
89
  if langname =="Faroese":
90
- rec_info += f", {ds['dialect'][0]}"
91
  return (graph.align_and_graph(sound_path,transcript,lang_aligner),sound_path,rec_info)
92
 
93
 
 
45
  elif langname =="Faroese":
46
  df = datas.ds_f
47
 
48
+ dfd = df.drop(columns=['audio', 'speaker_id','duration'])
 
49
  return (df, dfd[:15], "all") #(df, df[:50])
50
 
51
 
 
61
  # filter by dialect
62
 
63
  if gender != "all":
64
+ df = df[df.gender.str.startswith(gender)]
65
 
66
  #if age != "all":
67
  # df = df.filter(lambda x: x["age"] == age)
68
 
69
 
70
+ dfd = df.drop(columns=['audio', 'speaker_id','duration'])
 
71
  return (df,dfd[:15])
72
 
73
 
 
77
  elif langname =="Faroese":
78
  lang_aligner = datas.a_f
79
 
80
+
81
+ ex = ds.sample()
82
+ sound_path = ex['audio'].iloc[0]['path']
83
+ transcript = ex['normalized_text'].iloc[0]
 
84
 
85
+ rec_info = f"{ex['audio_id'].iloc[0]}, {ex['gender'].iloc[0]}, {ex['age'].iloc[0]}"
86
  if langname =="Faroese":
87
+ rec_info += f", {ex['dialect'].iloc[0]}"
88
  return (graph.align_and_graph(sound_path,transcript,lang_aligner),sound_path,rec_info)
89
 
90