kevinwang676 commited on
Commit
b9fbc8c
·
verified ·
1 Parent(s): 4e9d252

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -308,14 +308,14 @@ import shutil
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,12 +336,12 @@ def change_speed(audio_inp, speed=1.0):
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
@@ -399,7 +399,7 @@ def denoise(input_files):
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
 
 
308
 
309
  import zipfile
310
 
311
+ def zip_sliced_files(directory, zip_filename, chosen_name):
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"{chosen_name}") 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, chosen_name):
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"{chosen_name}"):
345
  # Create the complete file path
346
  file_path = os.path.join(foldername, filename)
347
  # Delete the file
 
399
  # os.remove("audio_full.wav")
400
  for video_file in input_files:
401
 
402
+ ffmpeg.input(video_file).output("input_video" + video_file + ".wav", ac=2, ar=44100).run()
403
 
404
  zip_sliced_files("./", "转换后的音频.zip", "input_video")
405