Spaces:
Sleeping
Sleeping
ASG Models
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -130,41 +130,28 @@ class DataViewerApp:
|
|
130 |
|
131 |
return self.get_page_data(self.current_page)
|
132 |
def trim_audio(self, text,data_oudio):
|
133 |
-
# Load audio
|
134 |
-
#row = self.data.iloc[self.current_selected]
|
135 |
-
#row['text'] = text # Use .loc for safer row modification
|
136 |
-
#self.data.iloc[self.current_selected] = row
|
137 |
audios_data = []
|
138 |
audios_samplerate = []
|
139 |
-
|
140 |
sr,audio=data_oudio
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
#self.data =self.df[['text','speaker_id','secs']]
|
161 |
-
|
162 |
-
|
163 |
-
#self.sdata =df['audio'].to_list()
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
#return self.data,5.8
|
168 |
def connect_drive(self):
|
169 |
from google.colab import drive
|
170 |
drive.mount('/content/drive')
|
|
|
130 |
|
131 |
return self.get_page_data(self.current_page)
|
132 |
def trim_audio(self, text,data_oudio):
|
|
|
|
|
|
|
|
|
133 |
audios_data = []
|
134 |
audios_samplerate = []
|
|
|
135 |
sr,audio=data_oudio
|
136 |
+
audio=audio.astype(np.float32)
|
137 |
+
audio/=np.max(np.abs(audio))
|
138 |
+
audio=librosa.resample(audio,orig_sr=sr,target_sr=16000)
|
139 |
+
audios_data.append(audio)
|
140 |
+
secs=round(len(audios_data)/16000,2)
|
141 |
+
audios_samplerate.append(16000)
|
142 |
+
df = pd.DataFrame()
|
143 |
+
df['secs'] = secs
|
144 |
+
df['audio'] =[ audio]
|
145 |
+
df['samplerate'] = 16000
|
146 |
+
df['text'] =text
|
147 |
+
df['speaker_id'] =self.speaker_id
|
148 |
+
df['_speaker_id'] =self.speaker_id
|
149 |
+
df['flag']=1
|
150 |
+
df = df[['text','audio','samplerate','secs','speaker_id','_speaker_id','flag']]
|
151 |
+
self.df = pd.concat([self.df, df], axis=0, ignore_index=True)
|
152 |
+
self.data =self.df[['text','speaker_id','secs','flag']]
|
153 |
+
self.sdata =self.df['audio'].to_list()
|
154 |
+
return self.get_page_data(self.current_page)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
def connect_drive(self):
|
156 |
from google.colab import drive
|
157 |
drive.mount('/content/drive')
|