Spaces:
Sleeping
Sleeping
ASG Models
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,419 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
import numpy as np
|
4 |
+
from df.enhance import enhance, init_df, load_audio, save_audio
|
5 |
|
|
|
|
|
6 |
|
7 |
+
def Read_DataSet(link):
|
8 |
+
dataset = DatasetDict.load_from_disk(link)
|
9 |
+
df = dataset["train"].to_pandas()
|
10 |
+
return df
|
11 |
+
|
12 |
+
|
13 |
+
def remove_nn(wav, sample_rate=16000):
|
14 |
+
sf.write("full_generation.wav", wav, sample_rate, format='WAV')
|
15 |
+
audio, _ = load_audio('full_generation.wav', sr=df_state.sr())
|
16 |
+
enhanced = enhance(model_enhance, df_state, audio)
|
17 |
+
save_audio("enhanced.wav", enhanced, df_state.sr())
|
18 |
+
audiodata, samplerate = librosa.load("enhanced.wav", sr=16000)
|
19 |
+
return 16000, audiodata
|
20 |
+
class DataViewerApp:
|
21 |
+
def __init__(self,df):
|
22 |
+
#df=Read_DataSet(link)
|
23 |
+
self.df=df
|
24 |
+
# self.df1=df
|
25 |
+
self.data =self.df[['text','speaker_id','secs','flag']]
|
26 |
+
self.dataa =self.df[['text','speaker_id','secs','flag']]
|
27 |
+
self.sdata =self.df['audio'].to_list() # Separate audio data storage
|
28 |
+
self.current_page = 0
|
29 |
+
self.current_selected = -1
|
30 |
+
self.speaker_id= -1
|
31 |
+
class Seafoam(Base):
|
32 |
+
pass
|
33 |
+
self.seafoam = Seafoam()
|
34 |
+
|
35 |
+
#self.data =df[['text','speaker_id']]
|
36 |
+
#self.sdata = df['audio'].to_list() # Separate audio data storage
|
37 |
+
#self.current_page = 0
|
38 |
+
#self.current_selected = -1
|
39 |
+
|
40 |
+
def settt(self,df):
|
41 |
+
self.df=pd.DataFrame()
|
42 |
+
self.data =pd.DataFrame()
|
43 |
+
self.sdata =[]
|
44 |
+
self.df=df
|
45 |
+
self.data =df[['text','speaker_id','secs','flag']]
|
46 |
+
self.dataa =df[['text','speaker_id','secs','flag']]
|
47 |
+
self.sdata =df['audio'].to_list()
|
48 |
+
self.current_page = 0
|
49 |
+
self.current_selected =1
|
50 |
+
self.speaker_id= -1
|
51 |
+
return self.data
|
52 |
+
def splitt(self,link,num):
|
53 |
+
df=download_youtube_video(link,num)
|
54 |
+
v=self.settt(df)
|
55 |
+
return self.get_page_data(self.current_page),len(v)
|
56 |
+
def getdataset(self,link):
|
57 |
+
df=Read_DataSet(link)
|
58 |
+
v=self.settt(df)
|
59 |
+
return self.get_page_data(self.current_page),len(v)
|
60 |
+
def remove_hamza_from_alif_and_symbols(self,text):
|
61 |
+
text = re.sub(r"[أإآ]", "ا", text)
|
62 |
+
text = re.sub(r"ٱ", "ا", text)
|
63 |
+
text = re.sub(r"[_\-\+\,\(\)]", " ", text)
|
64 |
+
text = re.sub(r"\d", " ", text)
|
65 |
+
return text
|
66 |
+
def save_row(self, text,data_oudio):
|
67 |
+
row = self.data.iloc[self.current_selected]
|
68 |
+
row['text'] = text
|
69 |
+
row['flag']=1
|
70 |
+
self.data.iloc[self.current_selected] = row
|
71 |
+
sr,audio=data_oudio
|
72 |
+
if sr!=16000:
|
73 |
+
sf.write("temp.wav", audio, sr,format='WAV')
|
74 |
+
audio, samplerate = librosa.load("temp.wav", sr=16000)
|
75 |
+
|
76 |
+
self.sdata[self.current_selected] = audio
|
77 |
+
return self.get_page_data(self.current_page)
|
78 |
+
def GetDataset_2(self,filename,ds=1.5):
|
79 |
+
audios_data = []
|
80 |
+
audios_samplerate = []
|
81 |
+
num_specker=[]
|
82 |
+
texts=[]
|
83 |
+
secs=[]
|
84 |
+
|
85 |
+
audiodata,samplerate = librosa.load(filename, sr=16000) # Removed extra indent here
|
86 |
+
audios_data.append(audiodata*ds)
|
87 |
+
audios_samplerate.append(samplerate)
|
88 |
+
texts.append(filename.replace('.wav',''))
|
89 |
+
secs.append(round(len(audiodata)/samplerate,2))
|
90 |
+
df = pd.DataFrame()
|
91 |
+
df['secs'] = secs
|
92 |
+
df['audio'] = audios_data
|
93 |
+
df['samplerate'] = audios_samplerate
|
94 |
+
df['text'] =os.path.splitext(os.path.basename(filename))[0]
|
95 |
+
df['speaker_id'] =self.speaker_id
|
96 |
+
df['_speaker_id'] =self.speaker_id
|
97 |
+
df['flag']=1
|
98 |
+
df = df[['text','audio','samplerate','secs','speaker_id','_speaker_id','flag']]
|
99 |
+
self.df = pd.concat([self.df, df], axis=0, ignore_index=True)
|
100 |
+
self.data =self.df[['text','speaker_id','secs','flag']]
|
101 |
+
self.sdata =self.df['audio'].to_list()
|
102 |
+
|
103 |
+
return self.get_page_data(self.current_page)
|
104 |
+
def trim_audio(self, text,data_oudio):
|
105 |
+
# Load audio
|
106 |
+
#row = self.data.iloc[self.current_selected]
|
107 |
+
#row['text'] = text # Use .loc for safer row modification
|
108 |
+
#self.data.iloc[self.current_selected] = row
|
109 |
+
audios_data = []
|
110 |
+
audios_samplerate = []
|
111 |
+
|
112 |
+
sr,audio=data_oudio
|
113 |
+
#if sr!=16000:
|
114 |
+
namefile=f"{text}.wav"
|
115 |
+
sf.write(namefile, audio, sr,format='WAV')
|
116 |
+
return self.GetDataset_2(namefile)
|
117 |
+
#audio, samplerate = librosa.load("tempppp.wav", sr=16000)
|
118 |
+
#audios_data.append(audio)
|
119 |
+
# secs=round(len(audios_data)/samplerate,2)
|
120 |
+
#audios_samplerate.append(samplerate)
|
121 |
+
#else:
|
122 |
+
# secs=round(len(audio)/sr,2)
|
123 |
+
# audios_data.append(audio)
|
124 |
+
#audios_samplerate.append(sr)
|
125 |
+
#secs.append(round(len(audios_data)/samplerate,2))
|
126 |
+
#self.df['secs'] = secs
|
127 |
+
#self.df['audio'] = audios_data
|
128 |
+
#self.df['samplerate'] = sr
|
129 |
+
#self.df['text'] =text
|
130 |
+
#self.df =self.df[['text','audio','samplerate','secs']]
|
131 |
+
#self.df.reset_index(drop=True, inplace=True)
|
132 |
+
#self.data =self.df[['text','speaker_id','secs']]
|
133 |
+
|
134 |
+
|
135 |
+
#self.sdata =df['audio'].to_list()
|
136 |
+
|
137 |
+
|
138 |
+
|
139 |
+
#return self.data,5.8
|
140 |
+
def connect_drive(self):
|
141 |
+
from google.colab import drive
|
142 |
+
drive.mount('/content/drive')
|
143 |
+
def get_page_data(self, page_number):
|
144 |
+
start_index = page_number * 10
|
145 |
+
end_index = start_index + 10
|
146 |
+
return self.data.iloc[start_index:end_index]
|
147 |
+
def update_page(self, new_page):
|
148 |
+
self.current_page = new_page
|
149 |
+
return (
|
150 |
+
self.get_page_data(self.current_page),
|
151 |
+
self.current_page > 0,
|
152 |
+
self.current_page < len(self.data) // 10 - 1,
|
153 |
+
self.current_page
|
154 |
+
)
|
155 |
+
def clear_txt(self):
|
156 |
+
self.data['text'] =self.data['text'].apply(self.remove_hamza_from_alif_and_symbols)
|
157 |
+
return self.get_page_data(self.current_page)
|
158 |
+
def get_text_from_audio(self,audio):
|
159 |
+
|
160 |
+
sf.write("temp.wav", audio, 16000,format='WAV')
|
161 |
+
|
162 |
+
client = Client("MohamedRashad/Arabic-Whisper-CodeSwitching-Edition")
|
163 |
+
result = client.predict(
|
164 |
+
inputs=handle_file('temp.wav'),
|
165 |
+
api_name="/predict_1"
|
166 |
+
)
|
167 |
+
return result
|
168 |
+
def on_column_dropdown_change_operater(self,selected_column,selected_column1):
|
169 |
+
if selected_column1==">":
|
170 |
+
return self.data[self.data['secs'] > selected_column ]
|
171 |
+
elif selected_column1=="<":
|
172 |
+
return self.data[self.data['secs'] < selected_column]
|
173 |
+
elif selected_column1=="=":
|
174 |
+
return self.data[self.data['secs'] == selected_column]
|
175 |
+
else:
|
176 |
+
return self.data
|
177 |
+
# Perform actions based on the selected column
|
178 |
+
|
179 |
+
def on_column_dropdown_change(self,selected_column):
|
180 |
+
data=self.df1
|
181 |
+
if selected_column=="all":
|
182 |
+
|
183 |
+
return self.settt(data)
|
184 |
+
else:
|
185 |
+
data=data[data['speaker_id'] ==selected_column]
|
186 |
+
return self.settt(data)
|
187 |
+
|
188 |
+
# Perform actions based on the selected column
|
189 |
+
|
190 |
+
def on_select(self,evt:gr.SelectData):
|
191 |
+
index_now = evt.index[0]
|
192 |
+
self.current_selected = (self.current_page * 10) + index_now
|
193 |
+
row = self.data.iloc[self.current_selected]
|
194 |
+
row_audio = self.sdata[self.current_selected]
|
195 |
+
self.speaker_id=row['speaker_id']
|
196 |
+
return (16000, row_audio), row['text']
|
197 |
+
def finsh_data(self):
|
198 |
+
self.df['audio'] = self.sdata
|
199 |
+
self.df[['text','speaker_id','secs','flag']]=self.data
|
200 |
+
|
201 |
+
return self.df
|
202 |
+
def All_enhance(self):
|
203 |
+
for i in range(0,len(self.sdata)):
|
204 |
+
_,y=remove_nn(self.sdata[i])
|
205 |
+
self.sdata[i]=y
|
206 |
+
return self.data
|
207 |
+
|
208 |
+
return self.get_page_data(self.current_page)
|
209 |
+
def get_output_audio(self):
|
210 |
+
return self.sdata[self.current_selected] if self.current_selected >= 0 else None
|
211 |
+
def Convert_DataFreme_To_DataSet(self,namedata):
|
212 |
+
df=self.finsh_data()
|
213 |
+
|
214 |
+
df['audio'] = df['audio'].apply(lambda x: np.array(x, dtype=np.float32))
|
215 |
+
if "__index_level_0__" in df.columns:
|
216 |
+
df =df.drop(columns=["__index_level_0__"])
|
217 |
+
train_df =df
|
218 |
+
|
219 |
+
eval_df =df.sample(1,random_state=42)
|
220 |
+
|
221 |
+
ds = {
|
222 |
+
"train": Dataset.from_pandas(train_df),
|
223 |
+
"eval": Dataset.from_pandas(eval_df),
|
224 |
+
"full_generation":Dataset.from_pandas(eval_df)
|
225 |
+
}
|
226 |
+
|
227 |
+
dataset = DatasetDict(ds)
|
228 |
+
dirr='/content/drive/MyDrive/vitsM/DATA/sata/'+namedata
|
229 |
+
dataset.save_to_disk(dirr)
|
230 |
+
return dirr
|
231 |
+
|
232 |
+
def delete_row(self):
|
233 |
+
|
234 |
+
self.data.drop(self.current_selected, inplace=True)
|
235 |
+
self.data.reset_index(drop=True, inplace=True)
|
236 |
+
self.df.drop(self.current_selected, inplace=True)
|
237 |
+
self.df.reset_index(drop=True, inplace=True)
|
238 |
+
self.sdata.pop(self.current_selected)
|
239 |
+
self.current_selected = -1
|
240 |
+
# self.audio_player.update(None) # Clear audio player
|
241 |
+
# self.txt_audio.update("") # Clear text input
|
242 |
+
|
243 |
+
return self.get_page_data(self.current_page)
|
244 |
+
def start_tab1(self):
|
245 |
+
with gr.Blocks(theme=self.seafoam, css="""
|
246 |
+
.checkbox-group label {
|
247 |
+
background-color: #f0f0f5; /* لون خلفية فاتح */
|
248 |
+
padding: 10px;
|
249 |
+
border-radius: 5px; /* زوايا دائرية */
|
250 |
+
}
|
251 |
+
const textbox = document.querySelector('.txt_audio'); // تحديد المكون النصي
|
252 |
+
textbox.style.direction = 'ltr';
|
253 |
+
.checkbox-group input:checked + label {
|
254 |
+
background-color: #e0f0ff; /* لون خلفية عند التحديد */
|
255 |
+
font-weight: bold;
|
256 |
+
}
|
257 |
+
""") as demo:
|
258 |
+
|
259 |
+
with gr.Row(equal_height=False):
|
260 |
+
with gr.Tabs():
|
261 |
+
with gr.TabItem("Processing Data "):
|
262 |
+
self.data_Processing()
|
263 |
+
return demo
|
264 |
+
def create_Tabs(self): # fix: method was missing
|
265 |
+
#with gr.Blocks() as interface:
|
266 |
+
with gr.Tabs():
|
267 |
+
with gr.TabItem("Excel"):
|
268 |
+
with gr.Row():
|
269 |
+
txt_filepath_excel=gr.Text("NameFile")
|
270 |
+
txt_text_excel=gr.Text("Text" )
|
271 |
+
but_send_excel=gr.Button("Send",size="sm")
|
272 |
+
|
273 |
+
with gr.TabItem("CVC"):
|
274 |
+
with gr.Row():
|
275 |
+
txt_filepath_cvc=gr.Text("File")
|
276 |
+
txt_text_cvc=gr.Text("Text" )
|
277 |
+
but_send_cvc=gr.Button("Send",size="sm")
|
278 |
+
with gr.TabItem("DateSet"):
|
279 |
+
self.txt_filepath_dir=gr.Text("link dir",interactive=True)
|
280 |
+
#self.txt_text=gr.Text("Text" )
|
281 |
+
self.but_send_dir=gr.Button("Send",size="sm")
|
282 |
+
with gr.TabItem("Dir"):
|
283 |
+
txt_filepath_dateSet=gr.Text("link DateSet")
|
284 |
+
#self.txt_text=gr.Text("Text" )
|
285 |
+
but_send_dateSet=gr.Button("Send",size="sm")
|
286 |
+
with gr.TabItem("Cut Video"):
|
287 |
+
self.txt_filepath_dateSet=gr.Text("رابط الفيديو",interactive=True)
|
288 |
+
self.num = gr.Number(label=" ادخل رقم طبيعي")
|
289 |
+
|
290 |
+
self.but_send_dateSet_cut=gr.Button("Send",size="sm")
|
291 |
+
|
292 |
+
def Convert_DataFrame_to_Bitch(self):
|
293 |
+
with gr.Row():
|
294 |
+
self.txt_output_dir=gr.Text("output Name dir",interactive=True)
|
295 |
+
self.txt_train_batch_size=gr.Text("train_batch_size",interactive=True)
|
296 |
+
self.txt_eval_batch_size=gr.Text("eval_batch_size",interactive=True )
|
297 |
+
self.but_convert_bitch=gr.Button("Convert Bitch",size="sm")
|
298 |
+
with gr.Row():
|
299 |
+
self.label_Bitch=gr.Label("Dir Output Bitch :")
|
300 |
+
|
301 |
+
|
302 |
+
def data_Processing(self):
|
303 |
+
|
304 |
+
#with gr.Column(scale=2,min_width=40):
|
305 |
+
|
306 |
+
#with gr.Row():
|
307 |
+
#with gr.Accordion("Open Data", open=False):
|
308 |
+
#with gr.Row():
|
309 |
+
# self.txt_filepath_dateSet=gr.Text("link DateSet",interactive=True)
|
310 |
+
#self.txt_text=gr.Text("Text" )
|
311 |
+
#self.but_send_dateSet=gr.Button("Send",size="sm")
|
312 |
+
|
313 |
+
|
314 |
+
with gr.Accordion("Install Data", open=False):
|
315 |
+
with gr.Row():
|
316 |
+
self.create_Tabs()
|
317 |
+
with gr.Row():
|
318 |
+
columns = []
|
319 |
+
columns1 = []
|
320 |
+
|
321 |
+
columns =unique_speaker_ids =self.df['speaker_id'].unique().tolist()
|
322 |
+
columns.append("all")
|
323 |
+
self.labell=gr.Label("count:")
|
324 |
+
self.column_dropdown = gr.Dropdown(choices=columns, label="speaker_id")
|
325 |
+
with gr.Row():
|
326 |
+
|
327 |
+
columns1=unique_speaker_ids =self.df['secs'].unique().tolist()
|
328 |
+
columns1.append("all")
|
329 |
+
self.column_dropdown1 = gr.Dropdown(choices=columns1 , label="secs")
|
330 |
+
|
331 |
+
self.column_dropdown11 = gr.Dropdown(choices=["all","<",">","="], label="operater")
|
332 |
+
|
333 |
+
|
334 |
+
with gr.Row():
|
335 |
+
|
336 |
+
|
337 |
+
with gr.Column(scale=2):
|
338 |
+
gr.Markdown("## Data Viewer")
|
339 |
+
#d=self.get_page_data(self.current_page)
|
340 |
+
# Correct the indentation here:
|
341 |
+
self.data_table = gr.DataFrame( # Notice 'self.' here
|
342 |
+
value=self.get_page_data(self.current_page),
|
343 |
+
headers=["Text","speaker_id"])
|
344 |
+
|
345 |
+
# interactive=True
|
346 |
+
|
347 |
+
#self.data_table1 = gr.DataFrame(headers=[ "Text","Id_spiker"])
|
348 |
+
with gr.Row(equal_height=False):
|
349 |
+
self.prev_button = gr.Button("Previous Page",scale=1, size="sm")
|
350 |
+
self.page_number = gr.Number(value=self.current_page + 1, label="Page",scale=1)
|
351 |
+
self.next_button = gr.Button("Next Page",scale=1, size="sm")
|
352 |
+
|
353 |
+
with gr.Row(equal_height=False):
|
354 |
+
|
355 |
+
#inputs=gr.CheckboxGroup(["John", "Mary", "Peter", "Susan"])
|
356 |
+
self.but_cleartxt=gr.Button("clear Text",variant="primary")
|
357 |
+
self.btn_all_enhance=gr.Button("All enhance",size="sm",variant="primary")
|
358 |
+
|
359 |
+
|
360 |
+
|
361 |
+
|
362 |
+
|
363 |
+
|
364 |
+
|
365 |
+
|
366 |
+
|
367 |
+
|
368 |
+
with gr.Column(scale=1):
|
369 |
+
gr.Markdown("## Row Data")
|
370 |
+
self.txt_audio = gr.Textbox(label="Text", interactive=True,rtl=True)
|
371 |
+
|
372 |
+
self.audio_player = gr.Audio(label="Audio")
|
373 |
+
self.btn_del = gr.Button("Delete ", size="sm",variant="primary")
|
374 |
+
self.btn_save = gr.Button("Save", size="sm",variant="primary")
|
375 |
+
self.totext=gr.Button("to text",size="sm" ,variant="primary")
|
376 |
+
self.btn_newsave=gr.Button("New Save Cut",size="sm",variant="primary")
|
377 |
+
self.btn_enhance = gr.Button("enhance ", size="sm",variant="primary")
|
378 |
+
self.order= gr.Button("order ", size="sm",variant="primary")
|
379 |
+
# self.btn_all_enhance=gr.Button("All enhance",size="sm")
|
380 |
+
|
381 |
+
|
382 |
+
|
383 |
+
|
384 |
+
with gr.Row(equal_height=False,variant="heading-1"):
|
385 |
+
with gr.Accordion("Save Bitch", open=False):
|
386 |
+
|
387 |
+
self.txt_dataset=gr.Text("save dataset",interactive=True)
|
388 |
+
self.btn_convertDataset=gr.Button("Dir Output Bitch :",variant="primary")
|
389 |
+
self.label_dataset=gr.Label("count:")
|
390 |
+
self.but_send_dir.click(self.getdataset, [self.txt_filepath_dir],[self.data_table,self.labell])
|
391 |
+
#self.but_send_dateSet_cut.click(self.splitt, [self.txt_filepath_dateSet,self.num],[self.data_table,self.labell])
|
392 |
+
#self.txt_audio.Style(container=False, css=".txt_audio { direction: rtl; }")
|
393 |
+
#self.but_send_dateSet.click(self.Read_DataSet, [self.txt_filepath_dateSet],[self.data_table ])
|
394 |
+
self.data_table.select(self.on_select, None, [self.audio_player, self.txt_audio])
|
395 |
+
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])
|
396 |
+
#self.btn_save.click(self.save_row, [self.txt_audio,self.audio_player], [self.data_table])
|
397 |
+
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])
|
398 |
+
self.column_dropdown.change(self.on_column_dropdown_change,[self.column_dropdown], [self.data_table])
|
399 |
+
self.column_dropdown11.change(self.on_column_dropdown_change_operater,[self.column_dropdown1,self.column_dropdown11], [self.data_table])
|
400 |
+
self.btn_convertDataset.click(self.Convert_DataFreme_To_DataSet,[self.txt_dataset],[self.label_dataset])
|
401 |
+
self.totext.click(lambda:self.get_text_from_audio(self.get_output_audio()), [], self.txt_audio)
|
402 |
+
self.btn_newsave.click(self.trim_audio,[self.txt_audio,self.audio_player],[self.data_table])
|
403 |
+
self.btn_save.click(self.save_row, [self.txt_audio,self.audio_player], [self.data_table])
|
404 |
+
#self.btn_save.click(self.save_row, [self.txt_audio,self.audio_player], [self.data_table])
|
405 |
+
self.btn_all_enhance.click(self.All_enhance,[],[self.data_table])
|
406 |
+
#self.btn_enhance.click(remove_nn, [self.audio_player], [self.audio_player])
|
407 |
+
self.but_cleartxt.click(self.clear_txt,[],[self.data_table])
|
408 |
+
self.btn_del.click(self.delete_row,[], [self.data_table])
|
409 |
+
self.btn_enhance.click(lambda: remove_nn(self.get_output_audio()), [], self.audio_player)
|
410 |
+
#self.column_dropdown.change(lambda selected_column:self.settt(self.on_column_dropdown_change(selected_column)), [self.column_dropdown], [self.data_table])
|
411 |
+
#self.column_dropdown.change(lambda selected_column:self.settt(x.on_column_dropdown_change(selected_column)), [x.column_dropdown], [self.data_table])
|
412 |
+
#self.btn_denoise.click(self.remove_nn, [self.audio_player], [self.audio_player])
|
413 |
+
|
414 |
+
|
415 |
+
|
416 |
+
dff=pd.DataFrame(columns=['text', 'audio', 'samplerate', 'secs', 'speaker_id', '_speaker_id','flag'])
|
417 |
+
app=DataViewerApp(dff)
|
418 |
+
s=app.start_tab1()
|
419 |
+
s.launch()
|