kevinwang676 commited on
Commit
87b7c95
Β·
verified Β·
1 Parent(s): 40d4af7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -12
app.py CHANGED
@@ -308,14 +308,14 @@ import shutil
308
 
309
  import zipfile
310
 
311
- def zip_sliced_files(directory, zip_filename):
312
  # Create a ZipFile object
313
  with zipfile.ZipFile(zip_filename, 'w') as zipf:
314
  # Iterate over all files in the directory
315
  for foldername, subfolders, filenames in os.walk(directory):
316
  for filename in filenames:
317
  # Check if the file starts with "sliced" and has a .wav extension
318
- if filename.startswith("sliced") and filename.endswith(".wav"):
319
  # Create the complete file path
320
  file_path = os.path.join(foldername, filename)
321
  # Add the file to the zip file
@@ -336,12 +336,12 @@ def change_speed(audio_inp, speed=1.0):
336
 
337
  # delete files first
338
 
339
- def delete_sliced_files(directory):
340
  # Iterate over all files in the directory
341
  for foldername, subfolders, filenames in os.walk(directory):
342
  for filename in filenames:
343
  # Check if the file starts with "sliced"
344
- if filename.startswith("sliced"):
345
  # Create the complete file path
346
  file_path = os.path.join(foldername, filename)
347
  # Delete the file
@@ -352,7 +352,7 @@ def delete_sliced_files(directory):
352
  def convert_from_srt(api_key, filename, audio_full, voice, multilingual):
353
 
354
  subtitle_list = read_srt(filename)
355
- delete_sliced_files("./")
356
 
357
  #audio_data, sr = librosa.load(audio_full, sr=44100)
358
 
@@ -382,7 +382,7 @@ def convert_from_srt(api_key, filename, audio_full, voice, multilingual):
382
  pass
383
  merge_audios("output")
384
 
385
- zip_sliced_files("./", "ε‚θ€ƒιŸ³ι’‘.zip")
386
 
387
  return "AIι…ιŸ³η‰ˆ.wav", "ε‚θ€ƒιŸ³ι’‘.zip"
388
 
@@ -392,14 +392,19 @@ restart_markdown = ("""
392
 
393
  import ffmpeg
394
 
395
- def denoise(video_full):
396
-
397
- if os.path.exists("audio_full.wav"):
398
- os.remove("audio_full.wav")
 
 
 
 
 
 
399
 
400
- ffmpeg.input(video_full).output("audio_full.wav", ac=2, ar=44100).run()
401
 
402
- return "audio_full.wav"
403
 
404
 
405
  with gr.Blocks() as app:
 
308
 
309
  import zipfile
310
 
311
+ def zip_sliced_files(directory, zip_filename, filename):
312
  # Create a ZipFile object
313
  with zipfile.ZipFile(zip_filename, 'w') as zipf:
314
  # Iterate over all files in the directory
315
  for foldername, subfolders, filenames in os.walk(directory):
316
  for filename in filenames:
317
  # Check if the file starts with "sliced" and has a .wav extension
318
+ if filename.startswith(f"{filename}") and filename.endswith(".wav"):
319
  # Create the complete file path
320
  file_path = os.path.join(foldername, filename)
321
  # Add the file to the zip file
 
336
 
337
  # delete files first
338
 
339
+ def delete_sliced_files(directory, filename):
340
  # Iterate over all files in the directory
341
  for foldername, subfolders, filenames in os.walk(directory):
342
  for filename in filenames:
343
  # Check if the file starts with "sliced"
344
+ if filename.startswith(f"{filename}"):
345
  # Create the complete file path
346
  file_path = os.path.join(foldername, filename)
347
  # Delete the file
 
352
  def convert_from_srt(api_key, filename, audio_full, voice, multilingual):
353
 
354
  subtitle_list = read_srt(filename)
355
+ delete_sliced_files("./", "sliced")
356
 
357
  #audio_data, sr = librosa.load(audio_full, sr=44100)
358
 
 
382
  pass
383
  merge_audios("output")
384
 
385
+ zip_sliced_files("./", "ε‚θ€ƒιŸ³ι’‘.zip", "sliced")
386
 
387
  return "AIι…ιŸ³η‰ˆ.wav", "ε‚θ€ƒιŸ³ι’‘.zip"
388
 
 
392
 
393
  import ffmpeg
394
 
395
+ def denoise(input_files):
396
+ delete_sliced_files("./", "input_video")
397
+
398
+ #if os.path.exists("audio_full.wav"):
399
+ # os.remove("audio_full.wav")
400
+ for video_file in input_files:
401
+
402
+ ffmpeg.input(video_file).output("input_video" + video_file.name + ".wav", ac=2, ar=44100).run()
403
+
404
+ zip_sliced_files("./", "θ½¬ζ’εŽηš„ιŸ³ι’‘.zip", "input_video")
405
 
 
406
 
407
+ return "θ½¬ζ’εŽηš„ιŸ³ι’‘.zip"
408
 
409
 
410
  with gr.Blocks() as app: