Spaces:
Build error
Build error
Upload moonarch_vocal_remover.py
Browse files- moonarch_vocal_remover.py +27 -0
moonarch_vocal_remover.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from spleeter.separator import Separator
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
class VocalRemover:
|
| 5 |
+
def __init__(self, input_path, task='spleeter:2stems'):
|
| 6 |
+
self.input_path = input_path
|
| 7 |
+
self.task = task
|
| 8 |
+
self.separator = Separator(self.task)
|
| 9 |
+
|
| 10 |
+
def separate_audio(self):
|
| 11 |
+
output_path = os.getcwd() # Use current directory as output path
|
| 12 |
+
|
| 13 |
+
# Create output directory if it doesn't exist
|
| 14 |
+
os.makedirs(output_path, exist_ok=True)
|
| 15 |
+
|
| 16 |
+
# Perform the separation
|
| 17 |
+
self.separator.separate_to_file(self.input_path, output_path)
|
| 18 |
+
|
| 19 |
+
def run(self):
|
| 20 |
+
# Perform the separation
|
| 21 |
+
self.separate_audio()
|
| 22 |
+
|
| 23 |
+
print("Separation completed")
|
| 24 |
+
|
| 25 |
+
# Example usage
|
| 26 |
+
#splitter = AdvanceSplitter('SS.mp3')
|
| 27 |
+
#splitter.run()
|