Awell00 commited on
Commit
d9d3a0c
·
verified ·
1 Parent(s): e883a9a

fix: file upload handling for Gradio NamedString objects

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -27,17 +27,17 @@ def handle_file_upload(file):
27
  if file is None:
28
  return None, "No file uploaded"
29
 
30
- filename = Path(file.name).stem
31
- formatted_title = sanitize_filename(filename)
32
 
33
  input_path = os.path.join(INPUT_FOLDER, "wav", f"{formatted_title}.wav")
34
  os.makedirs(os.path.dirname(input_path), exist_ok=True)
35
 
36
- with open(input_path, "wb") as f:
37
- f.write(file.read())
38
 
39
  return input_path, formatted_title
40
-
41
  def run_inference(model_type, config_path, start_check_point, input_dir, output_dir, device_ids="0"):
42
  command = [
43
  "python", "inference.py",
 
27
  if file is None:
28
  return None, "No file uploaded"
29
 
30
+ filename = os.path.basename(file.name)
31
+ formatted_title = sanitize_filename(Path(filename).stem)
32
 
33
  input_path = os.path.join(INPUT_FOLDER, "wav", f"{formatted_title}.wav")
34
  os.makedirs(os.path.dirname(input_path), exist_ok=True)
35
 
36
+ # Copy the uploaded file to the input folder
37
+ shutil.copy(file.name, input_path)
38
 
39
  return input_path, formatted_title
40
+
41
  def run_inference(model_type, config_path, start_check_point, input_dir, output_dir, device_ids="0"):
42
  command = [
43
  "python", "inference.py",