wasmdashai commited on
Commit
01746ea
·
verified ·
1 Parent(s): 142bf38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -17
app.py CHANGED
@@ -100,15 +100,12 @@ class DataEditor:
100
  self.current_selected = (self.current_page * 10) + index_now
101
  row = self.data.iloc[self.current_selected]
102
  txt_audio = row['text']
103
- #row_audio = self.sdata[self.current_selected]
104
- #if row_audio == None:
105
- zeros_array = np.zeros(100)
106
- audio_array = np.zeros(10, dtype=np.float32)
107
- audio = librosa.resample(audio_array, orig_sr=16000, target_sr=16000)
108
- #audio=librosa.resample(zeros_array,orig_sr=16000,target_sr=16000)
109
- return txt_audio,None
110
- # else:
111
- return ""
112
 
113
  else:
114
  return None," "
@@ -116,19 +113,15 @@ class DataEditor:
116
  return self.get_page_data(self.current_page),None,""
117
 
118
  def on_row_save(self, text,data_oudio):
119
- if text!="" :
120
 
121
  row = self.data.iloc[self.current_selected]
122
  #row['text'] = text
123
  row['flag']=1
124
  self.data.iloc[self.current_selected] = row
125
- if data_oudio!=None:
126
- self.sdata[self.current_selected] = data_oudio
127
-
128
-
129
- return "",data_oudio
130
- else:
131
- return "",None
132
  def on_row_delete(self):
133
  if self.current_selected>=0:
134
  row = self.data.iloc[self.current_selected]
 
100
  self.current_selected = (self.current_page * 10) + index_now
101
  row = self.data.iloc[self.current_selected]
102
  txt_audio = row['text']
103
+ row_audio = self.sdata[self.current_selected]
104
+ if row['flag'] !=0:
105
+ return txt_audio,(44100,row_audio)
106
+ else :
107
+ return txt_audio,None
108
+
 
 
 
109
 
110
  else:
111
  return None," "
 
113
  return self.get_page_data(self.current_page),None,""
114
 
115
  def on_row_save(self, text,data_oudio):
116
+ if text!="" and data_oudio is not None:
117
 
118
  row = self.data.iloc[self.current_selected]
119
  #row['text'] = text
120
  row['flag']=1
121
  self.data.iloc[self.current_selected] = row
122
+ sr,audio_array=data_oudio
123
+ self.sdata[self.current_selected] =audio_array
124
+ return "",None
 
 
 
 
125
  def on_row_delete(self):
126
  if self.current_selected>=0:
127
  row = self.data.iloc[self.current_selected]