jhj0517 commited on
Commit
b7fa700
·
1 Parent(s): d317550

Update return type

Browse files
Files changed (1) hide show
  1. modules/uvr/music_separator.py +11 -9
modules/uvr/music_separator.py CHANGED
@@ -27,21 +27,23 @@ class MusicSeparator:
27
 
28
  def separate(self,
29
  audio_file_path: str,
30
- sample_rate: int = 44100):
 
31
  if self.model is None:
32
  self.model = self.update_model()
33
 
34
- filename = audio_file_path
35
- instrumental_output_path = os.path.join(self.output_dir, "instrumental", filename)
36
- vocals_output_path = os.path.join(self.output_dir, "vocals", filename)
37
-
38
  result = self.model(audio_file_path)
39
- instrumental, vocals = result["instrumental"], result["vocals"]
 
 
 
 
 
40
 
41
- sf.write('instrumental.wav', instrumental.T, sample_rate, format="WAV")
42
- sf.write('vocals.wav', vocals.T, sample_rate, format="WAV")
43
 
44
- return instrumental_output_path, vocals_output_path
45
 
46
  @staticmethod
47
  def get_device():
 
27
 
28
  def separate(self,
29
  audio_file_path: str,
30
+ sample_rate: int = 44100,
31
+ save_file: bool = True):
32
  if self.model is None:
33
  self.model = self.update_model()
34
 
 
 
 
 
35
  result = self.model(audio_file_path)
36
+ instrumental, vocals = result["instrumental"].T, result["vocals"].T
37
+
38
+ if save_file:
39
+ filename = audio_file_path
40
+ instrumental_output_path = os.path.join(self.output_dir, "instrumental", filename)
41
+ vocals_output_path = os.path.join(self.output_dir, "vocals", filename)
42
 
43
+ sf.write(instrumental_output_path, instrumental, sample_rate, format="WAV")
44
+ sf.write(vocals_output_path, vocals, sample_rate, format="WAV")
45
 
46
+ return instrumental, vocals
47
 
48
  @staticmethod
49
  def get_device():