fffiloni commited on
Commit
ae4e904
1 Parent(s): 5ef74b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -42,11 +42,28 @@ def get_wav_files(path):
42
  print(f"{subindent}{f}")
43
  return wav_files # Return the list of .wav file paths
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  def infer(video_in):
46
 
 
 
 
47
  # Need to find path to gradio temp vid from video input
48
- # path_to_video
49
-
50
  print(f"VIDEO IN PATH: {video_in}")
51
  # Get the directory name
52
  folder_path = os.path.dirname(video_in)
 
42
  print(f"{subindent}{f}")
43
  return wav_files # Return the list of .wav file paths
44
 
45
+ def check_outputs_folder(folder_path):
46
+ # Check if the folder exists
47
+ if os.path.exists(folder_path) and os.path.isdir(folder_path):
48
+ # Delete all contents inside the folder
49
+ for filename in os.listdir(folder_path):
50
+ file_path = os.path.join(folder_path, filename)
51
+ try:
52
+ if os.path.isfile(file_path) or os.path.islink(file_path):
53
+ os.unlink(file_path) # Remove file or link
54
+ elif os.path.isdir(file_path):
55
+ shutil.rmtree(file_path) # Remove directory
56
+ except Exception as e:
57
+ print(f'Failed to delete {file_path}. Reason: {e}')
58
+ else:
59
+ print(f'The folder {folder_path} does not exist.')
60
+
61
  def infer(video_in):
62
 
63
+ # check if 'outputs' dir exists and empty it if necessary
64
+ check_outputs_folder('./outputs/tmp')
65
+
66
  # Need to find path to gradio temp vid from video input
 
 
67
  print(f"VIDEO IN PATH: {video_in}")
68
  # Get the directory name
69
  folder_path = os.path.dirname(video_in)