Roman commited on
Commit
8222c39
·
verified ·
1 Parent(s): 9265b5b

Update demucs_split.py

Browse files
Files changed (1) hide show
  1. demucs_split.py +19 -31
demucs_split.py CHANGED
@@ -1,32 +1,20 @@
1
- import demucs.separate
2
- import os
3
- import shutil
4
- import json
5
- import time
6
-
7
- def clear_folder(folder_path):
8
- for item in os.listdir(folder_path):
9
- item_path = os.path.join(folder_path, item)
10
- if os.path.isfile(item_path) or os.path.islink(item_path):
11
- os.unlink(item_path)
12
- else:
13
- shutil.rmtree(item_path)
14
-
15
- def demucs_split(
16
- url_or_path: str,
17
- demucs_model: str = "mdx_extra"
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"