Spaces:
Running
Running
jhj0517
commited on
Commit
·
770e792
1
Parent(s):
598f1d1
Return file path
Browse files
modules/uvr/music_separator.py
CHANGED
|
@@ -65,6 +65,11 @@ class MusicSeparator:
|
|
| 65 |
self.audio_info = torchaudio.info(audio_file_path)
|
| 66 |
sample_rate = self.audio_info.sample_rate
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
model_config = {
|
| 69 |
"segment": segment_size,
|
| 70 |
"split": True
|
|
@@ -84,16 +89,10 @@ class MusicSeparator:
|
|
| 84 |
result = self.model(audio_file_path)
|
| 85 |
instrumental, vocals = result["instrumental"].T, result["vocals"].T
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
filename = os.path.basename(filename) + ".wav"
|
| 90 |
-
instrumental_output_path = os.path.join(self.output_dir, "instrumental", filename)
|
| 91 |
-
vocals_output_path = os.path.join(self.output_dir, "vocals", filename)
|
| 92 |
-
|
| 93 |
-
sf.write(instrumental_output_path, instrumental, sample_rate, format="WAV")
|
| 94 |
-
sf.write(vocals_output_path, vocals, sample_rate, format="WAV")
|
| 95 |
|
| 96 |
-
return
|
| 97 |
|
| 98 |
@staticmethod
|
| 99 |
def get_device():
|
|
|
|
| 65 |
self.audio_info = torchaudio.info(audio_file_path)
|
| 66 |
sample_rate = self.audio_info.sample_rate
|
| 67 |
|
| 68 |
+
filename, ext = os.path.splitext(audio_file_path)
|
| 69 |
+
filename = os.path.basename(filename) + ".wav"
|
| 70 |
+
instrumental_output_path = os.path.join(self.output_dir, "instrumental", filename)
|
| 71 |
+
vocals_output_path = os.path.join(self.output_dir, "vocals", filename)
|
| 72 |
+
|
| 73 |
model_config = {
|
| 74 |
"segment": segment_size,
|
| 75 |
"split": True
|
|
|
|
| 89 |
result = self.model(audio_file_path)
|
| 90 |
instrumental, vocals = result["instrumental"].T, result["vocals"].T
|
| 91 |
|
| 92 |
+
sf.write(instrumental_output_path, instrumental, sample_rate, format="WAV")
|
| 93 |
+
sf.write(vocals_output_path, vocals, sample_rate, format="WAV")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
+
return instrumental_output_path, vocals_output_path
|
| 96 |
|
| 97 |
@staticmethod
|
| 98 |
def get_device():
|