Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from datasets import Dataset, DatasetDict
|
|
8 |
from datasets import load_dataset
|
9 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
10 |
model_enhance, df_state, _ = init_df()
|
11 |
-
def remove_nn(wav, sample_rate=
|
12 |
|
13 |
audio=librosa.resample(wav,orig_sr=sample_rate,target_sr=df_state.sr(),)
|
14 |
|
@@ -21,7 +21,7 @@ def remove_nn(wav, sample_rate=44100):
|
|
21 |
# save_audio("enhanced.wav", enhanced, df_state.sr())
|
22 |
audiodata=librosa.resample(enhanced[0].numpy(),orig_sr=df_state.sr(),target_sr=sample_rate)
|
23 |
|
24 |
-
return
|
25 |
class DataEditor:
|
26 |
def __init__(self,df):
|
27 |
self.df=df
|
@@ -120,7 +120,7 @@ class DataEditor:
|
|
120 |
txt_audio = row['text']
|
121 |
row_audio = self.sdata[self.current_selected]
|
122 |
if row['flag'] !=0:
|
123 |
-
return txt_audio,(
|
124 |
else :
|
125 |
return txt_audio,None
|
126 |
|
@@ -137,8 +137,13 @@ class DataEditor:
|
|
137 |
#row['text'] = text
|
138 |
row['flag']=1
|
139 |
self.data.iloc[self.current_selected] = row
|
140 |
-
sr,
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
142 |
return "",None
|
143 |
def on_row_delete(self):
|
144 |
if self.current_selected>=0:
|
|
|
8 |
from datasets import load_dataset
|
9 |
from df.enhance import enhance, init_df, load_audio, save_audio
|
10 |
model_enhance, df_state, _ = init_df()
|
11 |
+
def remove_nn(wav, sample_rate=16000):
|
12 |
|
13 |
audio=librosa.resample(wav,orig_sr=sample_rate,target_sr=df_state.sr(),)
|
14 |
|
|
|
21 |
# save_audio("enhanced.wav", enhanced, df_state.sr())
|
22 |
audiodata=librosa.resample(enhanced[0].numpy(),orig_sr=df_state.sr(),target_sr=sample_rate)
|
23 |
|
24 |
+
return 16000, audiodata/np.max(audiodata)
|
25 |
class DataEditor:
|
26 |
def __init__(self,df):
|
27 |
self.df=df
|
|
|
120 |
txt_audio = row['text']
|
121 |
row_audio = self.sdata[self.current_selected]
|
122 |
if row['flag'] !=0:
|
123 |
+
return txt_audio,(16000,row_audio)
|
124 |
else :
|
125 |
return txt_audio,None
|
126 |
|
|
|
137 |
#row['text'] = text
|
138 |
row['flag']=1
|
139 |
self.data.iloc[self.current_selected] = row
|
140 |
+
sr,audio=data_oudio
|
141 |
+
if sr!=16000:
|
142 |
+
audio=audio.astype(np.float32)
|
143 |
+
audio/=np.max(np.abs(audio))
|
144 |
+
audio=librosa.resample(audio,orig_sr=sr,target_sr=16000)
|
145 |
+
self.sdata[self.current_selected] =audio
|
146 |
+
|
147 |
return "",None
|
148 |
def on_row_delete(self):
|
149 |
if self.current_selected>=0:
|