Spaces:
Sleeping
Sleeping
wasmdashai
commited on
Commit
•
4e3bf01
1
Parent(s):
ea7f72a
Update app.py
Browse files
app.py
CHANGED
@@ -58,7 +58,9 @@ class DataViewerApp:
|
|
58 |
#self.sdata = df['audio'].to_list() # Separate audio data storage
|
59 |
#self.current_page = 0
|
60 |
#self.current_selected = -1
|
61 |
-
|
|
|
|
|
62 |
def settt(self,df):
|
63 |
self.df=pd.DataFrame()
|
64 |
self.data =pd.DataFrame()
|
@@ -115,6 +117,9 @@ class DataViewerApp:
|
|
115 |
|
116 |
|
117 |
self.sdata[self.current_selected] = audio
|
|
|
|
|
|
|
118 |
return self.get_page_data(self.current_page),None,""
|
119 |
def GetDataset_2(self,filename,ds=1.5):
|
120 |
audios_data = []
|
@@ -214,15 +219,16 @@ class DataViewerApp:
|
|
214 |
# Perform actions based on the selected column
|
215 |
|
216 |
def on_column_dropdown_change(self,selected_column):
|
217 |
-
data=self.
|
218 |
if selected_column=="all":
|
219 |
|
220 |
-
return self.
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
|
|
226 |
|
227 |
def on_select(self,evt:gr.SelectData):
|
228 |
index_now = evt.index[0]
|
@@ -246,7 +252,7 @@ class DataViewerApp:
|
|
246 |
def get_output_audio(self):
|
247 |
return self.sdata[self.current_selected] if self.current_selected >= 0 else None
|
248 |
def Convert_DataFreme_To_DataSet(self,namedata):
|
249 |
-
df=self.
|
250 |
|
251 |
df['audio'] = df['audio'].apply(lambda x: np.array(x, dtype=np.float32))
|
252 |
if "__index_level_0__" in df.columns:
|
@@ -378,7 +384,7 @@ class DataViewerApp:
|
|
378 |
columns = []
|
379 |
columns1 = []
|
380 |
|
381 |
-
columns =
|
382 |
columns.append("all")
|
383 |
self.labell=gr.Label("count:")
|
384 |
self.column_dropdown = gr.Dropdown(choices=columns, label="speaker_id")
|
@@ -462,7 +468,7 @@ class DataViewerApp:
|
|
462 |
self.prev_button.click(lambda page: self.update_page(page - 1), [self.page_number], [self.data_table, self.prev_button, self.next_button, self.page_number])
|
463 |
#self.btn_save.click(self.save_row, [self.txt_audio,self.audio_player], [self.data_table])
|
464 |
self.next_button.click(lambda page: self.update_page(page + 1), [self.page_number], [self.data_table, self.prev_button, self.next_button, self.page_number])
|
465 |
-
self.column_dropdown.change(self.on_column_dropdown_change,[self.column_dropdown], [self.data_table])
|
466 |
self.column_dropdown11.change(self.on_column_dropdown_change_operater,[self.column_dropdown1,self.column_dropdown11], [self.data_table])
|
467 |
self.btn_convertDataset.click(self.Convert_DataFreme_To_DataSet,[self.txt_dataset],[self.label_dataset])
|
468 |
self.totext.click(lambda:self.get_text_from_audio(self.get_output_audio()), [], self.txt_audio)
|
|
|
58 |
#self.sdata = df['audio'].to_list() # Separate audio data storage
|
59 |
#self.current_page = 0
|
60 |
#self.current_selected = -1
|
61 |
+
def set1(self,df):
|
62 |
+
self.data =df[['text','speaker_id','secs','flag']]
|
63 |
+
self.sdata =df['audio'].to_list()
|
64 |
def settt(self,df):
|
65 |
self.df=pd.DataFrame()
|
66 |
self.data =pd.DataFrame()
|
|
|
117 |
|
118 |
|
119 |
self.sdata[self.current_selected] = audio
|
120 |
+
self.df['text'][self.current_selected] =text
|
121 |
+
self.df['audio'][self.current_selected] = audio
|
122 |
+
self.df['flag'][self.current_selected] =1
|
123 |
return self.get_page_data(self.current_page),None,""
|
124 |
def GetDataset_2(self,filename,ds=1.5):
|
125 |
audios_data = []
|
|
|
219 |
# Perform actions based on the selected column
|
220 |
|
221 |
def on_column_dropdown_change(self,selected_column):
|
222 |
+
data=self.df
|
223 |
if selected_column=="all":
|
224 |
|
225 |
+
return self.set1(data),len(data)
|
226 |
+
elif selected_column=="0":
|
227 |
+
data=data[data['flag'] ==0]
|
228 |
+
return self.set1(data),len(data)
|
229 |
+
else :
|
230 |
+
data=data[data['flag'] ==1]
|
231 |
+
return self.set1(data),len(data)
|
232 |
|
233 |
def on_select(self,evt:gr.SelectData):
|
234 |
index_now = evt.index[0]
|
|
|
252 |
def get_output_audio(self):
|
253 |
return self.sdata[self.current_selected] if self.current_selected >= 0 else None
|
254 |
def Convert_DataFreme_To_DataSet(self,namedata):
|
255 |
+
df=self.df
|
256 |
|
257 |
df['audio'] = df['audio'].apply(lambda x: np.array(x, dtype=np.float32))
|
258 |
if "__index_level_0__" in df.columns:
|
|
|
384 |
columns = []
|
385 |
columns1 = []
|
386 |
|
387 |
+
columns =["all","0","1"]
|
388 |
columns.append("all")
|
389 |
self.labell=gr.Label("count:")
|
390 |
self.column_dropdown = gr.Dropdown(choices=columns, label="speaker_id")
|
|
|
468 |
self.prev_button.click(lambda page: self.update_page(page - 1), [self.page_number], [self.data_table, self.prev_button, self.next_button, self.page_number])
|
469 |
#self.btn_save.click(self.save_row, [self.txt_audio,self.audio_player], [self.data_table])
|
470 |
self.next_button.click(lambda page: self.update_page(page + 1), [self.page_number], [self.data_table, self.prev_button, self.next_button, self.page_number])
|
471 |
+
self.column_dropdown.change(self.on_column_dropdown_change,[self.column_dropdown], [self.data_table,self.labell])
|
472 |
self.column_dropdown11.change(self.on_column_dropdown_change_operater,[self.column_dropdown1,self.column_dropdown11], [self.data_table])
|
473 |
self.btn_convertDataset.click(self.Convert_DataFreme_To_DataSet,[self.txt_dataset],[self.label_dataset])
|
474 |
self.totext.click(lambda:self.get_text_from_audio(self.get_output_audio()), [], self.txt_audio)
|