Roman commited on
Update demucs_split.py
Browse files- demucs_split.py +19 -31
demucs_split.py
CHANGED
|
@@ -1,32 +1,20 @@
|
|
| 1 |
-
import demucs.separate
|
| 2 |
-
import os
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
input_file = "input.mp3"
|
| 21 |
-
|
| 22 |
-
def clean_temp():
|
| 23 |
-
clear_folder("splited_audio_output")
|
| 24 |
-
|
| 25 |
-
input_file = url_or_path
|
| 26 |
-
# Разделение аудио
|
| 27 |
-
print("Separating audio...")
|
| 28 |
-
os.environ['XDG_CACHE_HOME'] = "./models_demucs/"
|
| 29 |
-
demucs_opts = ["--mp3", "--two-stems", "vocals", "-n", demucs_model, input_file, "-o", "splited_audio_output", "--filename", "{stem}.mp3"]
|
| 30 |
-
demucs.separate.main(demucs_opts)
|
| 31 |
-
|
| 32 |
return f"splited_audio_output/{demucs_model}/vocals.mp3", f"splited_audio_output/{demucs_model}/no_vocals.mp3"
|
|
|
|
| 1 |
+
import demucs.separate
|
| 2 |
+
import os
|
| 3 |
+
def demucs_split(
|
| 4 |
+
url_or_path: str,
|
| 5 |
+
demucs_model: str = "mdx_extra"
|
| 6 |
+
):
|
| 7 |
+
|
| 8 |
+
input_file = "input.mp3"
|
| 9 |
+
|
| 10 |
+
def clean_temp():
|
| 11 |
+
clear_folder("splited_audio_output")
|
| 12 |
+
|
| 13 |
+
input_file = url_or_path
|
| 14 |
+
# Разделение аудио
|
| 15 |
+
print("Separating audio...")
|
| 16 |
+
os.environ['XDG_CACHE_HOME'] = "./models_demucs/"
|
| 17 |
+
demucs_opts = ["--mp3", "--two-stems", "vocals", "-n", demucs_model, input_file, "-o", "splited_audio_output", "--filename", "{stem}.mp3"]
|
| 18 |
+
demucs.separate.main(demucs_opts)
|
| 19 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
return f"splited_audio_output/{demucs_model}/vocals.mp3", f"splited_audio_output/{demucs_model}/no_vocals.mp3"
|