Spaces:
Sleeping
Sleeping
akshansh36
commited on
Commit
•
05c9fee
1
Parent(s):
d228293
Update app.py
Browse files
app.py
CHANGED
@@ -232,39 +232,31 @@ def run(audio_files, file_m, file_index):
|
|
232 |
file_m = os.path.join(model_dir, file_m)
|
233 |
file_index = os.path.join(model_dir, file_index) if file_index else None
|
234 |
|
235 |
-
if file_m is not None and file_m.endswith(".txt"):
|
236 |
-
file_m, file_index = find_my_model(file_m, file_index)
|
237 |
-
print(file_m, file_index)
|
238 |
-
|
239 |
random_tag = "USER_" + str(random.randint(10000000, 99999999))
|
240 |
|
241 |
-
pitch_alg = "rmvpe+"
|
242 |
-
pitch_lvl = 0
|
243 |
-
index_inf = 0.75
|
244 |
-
r_m_f = 3
|
245 |
-
e_r = 0.25
|
246 |
-
c_b_p = 0.5
|
247 |
-
|
248 |
converter.apply_conf(
|
249 |
tag=random_tag,
|
250 |
file_model=file_m,
|
251 |
-
pitch_algo=
|
252 |
-
pitch_lvl=
|
253 |
file_index=file_index,
|
254 |
-
index_influence=
|
255 |
-
respiration_median_filtering=
|
256 |
-
envelope_ratio=
|
257 |
-
consonant_breath_protection=
|
258 |
resample_sr=44100 if audio_files[0].endswith('.mp3') else 0,
|
259 |
)
|
260 |
time.sleep(0.1)
|
261 |
|
262 |
result = convert_now(audio_files, random_tag, converter)
|
263 |
-
|
264 |
result = apply_noisereduce(result)
|
265 |
|
266 |
-
#
|
267 |
-
|
|
|
|
|
|
|
|
|
268 |
|
269 |
|
270 |
def model_conf():
|
@@ -300,7 +292,7 @@ def button_conf():
|
|
300 |
)
|
301 |
|
302 |
def output_conf():
|
303 |
-
return gr.File(label="Result", file_count="multiple", interactive=False), gr.Audio(label="Play Result")
|
304 |
|
305 |
def get_gui(theme):
|
306 |
with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app:
|
@@ -313,34 +305,18 @@ def get_gui(theme):
|
|
313 |
output_file, output_audio = output_conf()
|
314 |
|
315 |
button_base.click(
|
316 |
-
|
317 |
-
inputs=[
|
318 |
-
aud,
|
319 |
-
model,
|
320 |
-
indx,
|
321 |
-
],
|
322 |
outputs=[output_file, output_audio],
|
323 |
)
|
324 |
|
325 |
gr.Examples(
|
326 |
examples=[
|
327 |
-
[
|
328 |
-
|
329 |
-
"./model.pth",
|
330 |
-
"./model.index",
|
331 |
-
],
|
332 |
-
[
|
333 |
-
["./example2/test2.ogg"],
|
334 |
-
"./example2/model.pth",
|
335 |
-
"./example2/model.index",
|
336 |
-
],
|
337 |
-
],
|
338 |
-
fn=run,
|
339 |
-
inputs=[
|
340 |
-
aud,
|
341 |
-
model,
|
342 |
-
indx,
|
343 |
],
|
|
|
|
|
344 |
outputs=[output_file, output_audio],
|
345 |
cache_examples=False,
|
346 |
)
|
|
|
232 |
file_m = os.path.join(model_dir, file_m)
|
233 |
file_index = os.path.join(model_dir, file_index) if file_index else None
|
234 |
|
|
|
|
|
|
|
|
|
235 |
random_tag = "USER_" + str(random.randint(10000000, 99999999))
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
converter.apply_conf(
|
238 |
tag=random_tag,
|
239 |
file_model=file_m,
|
240 |
+
pitch_algo="rmvpe+",
|
241 |
+
pitch_lvl=0,
|
242 |
file_index=file_index,
|
243 |
+
index_influence=0.75,
|
244 |
+
respiration_median_filtering=3,
|
245 |
+
envelope_ratio=0.25,
|
246 |
+
consonant_breath_protection=0.5,
|
247 |
resample_sr=44100 if audio_files[0].endswith('.mp3') else 0,
|
248 |
)
|
249 |
time.sleep(0.1)
|
250 |
|
251 |
result = convert_now(audio_files, random_tag, converter)
|
|
|
252 |
result = apply_noisereduce(result)
|
253 |
|
254 |
+
return result, result[0] # Assuming result is a list of file paths
|
255 |
+
|
256 |
+
|
257 |
+
def process_audio(audio_files, file_m, file_index):
|
258 |
+
result, first_audio = run(audio_files, file_m, file_index)
|
259 |
+
return result, gr.update(visible=True)
|
260 |
|
261 |
|
262 |
def model_conf():
|
|
|
292 |
)
|
293 |
|
294 |
def output_conf():
|
295 |
+
return gr.File(label="Result", file_count="multiple", interactive=False), gr.Audio(label="Play Result",visible=False)
|
296 |
|
297 |
def get_gui(theme):
|
298 |
with gr.Blocks(theme=theme, delete_cache=(3200, 3200)) as app:
|
|
|
305 |
output_file, output_audio = output_conf()
|
306 |
|
307 |
button_base.click(
|
308 |
+
process_audio,
|
309 |
+
inputs=[aud, model, indx],
|
|
|
|
|
|
|
|
|
310 |
outputs=[output_file, output_audio],
|
311 |
)
|
312 |
|
313 |
gr.Examples(
|
314 |
examples=[
|
315 |
+
["./test.ogg", "./model.pth", "./model.index"],
|
316 |
+
["./example2/test2.ogg", "./example2/model.pth", "./example2/model.index"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
],
|
318 |
+
fn=process_audio,
|
319 |
+
inputs=[aud, model, indx],
|
320 |
outputs=[output_file, output_audio],
|
321 |
cache_examples=False,
|
322 |
)
|