Update app.py
Browse files
app.py
CHANGED
|
@@ -62,14 +62,20 @@ def fast_align(source, target_len):
|
|
| 62 |
|
| 63 |
def separate_stems(input_file, job_id):
|
| 64 |
out_dir = f"sep_{job_id}"
|
| 65 |
-
|
|
|
|
| 66 |
"demucs",
|
| 67 |
"-n", "mdx_q",
|
| 68 |
"--two-stems=drums",
|
| 69 |
-
"--device", DEVICE,
|
| 70 |
"--out", out_dir,
|
| 71 |
input_file
|
| 72 |
-
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
base = os.path.splitext(os.path.basename(input_file))[0]
|
| 75 |
stem_dir = os.path.join(out_dir, "mdx_q", base)
|
|
@@ -187,6 +193,7 @@ def fuse_api():
|
|
| 187 |
|
| 188 |
except Exception as e:
|
| 189 |
return jsonify({"error": str(e)}), 500
|
|
|
|
| 190 |
finally:
|
| 191 |
for f in temp_files:
|
| 192 |
if os.path.exists(f):
|
|
@@ -194,5 +201,7 @@ def fuse_api():
|
|
| 194 |
for d in cleanup_dirs:
|
| 195 |
if os.path.exists(d):
|
| 196 |
shutil.rmtree(d, ignore_errors=True)
|
|
|
|
|
|
|
| 197 |
if __name__ == "__main__":
|
| 198 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 62 |
|
| 63 |
def separate_stems(input_file, job_id):
|
| 64 |
out_dir = f"sep_{job_id}"
|
| 65 |
+
|
| 66 |
+
cmd = [
|
| 67 |
"demucs",
|
| 68 |
"-n", "mdx_q",
|
| 69 |
"--two-stems=drums",
|
|
|
|
| 70 |
"--out", out_dir,
|
| 71 |
input_file
|
| 72 |
+
]
|
| 73 |
+
|
| 74 |
+
if DEVICE == "cuda":
|
| 75 |
+
cmd.insert(4, "--device")
|
| 76 |
+
cmd.insert(5, "cuda")
|
| 77 |
+
|
| 78 |
+
subprocess.run(cmd, check=True)
|
| 79 |
|
| 80 |
base = os.path.splitext(os.path.basename(input_file))[0]
|
| 81 |
stem_dir = os.path.join(out_dir, "mdx_q", base)
|
|
|
|
| 193 |
|
| 194 |
except Exception as e:
|
| 195 |
return jsonify({"error": str(e)}), 500
|
| 196 |
+
|
| 197 |
finally:
|
| 198 |
for f in temp_files:
|
| 199 |
if os.path.exists(f):
|
|
|
|
| 201 |
for d in cleanup_dirs:
|
| 202 |
if os.path.exists(d):
|
| 203 |
shutil.rmtree(d, ignore_errors=True)
|
| 204 |
+
|
| 205 |
+
|
| 206 |
if __name__ == "__main__":
|
| 207 |
app.run(host='0.0.0.0', port=7860)
|