Spaces:
Running
on
Zero
Running
on
Zero
use torchaudio instead of soundfile in separate speaker core
Browse files- gradio_app.py +3 -1
gradio_app.py
CHANGED
@@ -52,12 +52,14 @@ def separate_speakers_core(audio_path):
|
|
52 |
output_files = []
|
53 |
for i in range(ests_speech.shape[0]):
|
54 |
path = os.path.join(output_dir, f"speaker_{i+1}.wav")
|
55 |
-
|
|
|
56 |
output_files.append(path)
|
57 |
|
58 |
return output_files
|
59 |
|
60 |
|
|
|
61 |
@spaces.GPU()
|
62 |
def separate_dnr(audio_file):
|
63 |
audio, sr = torchaudio.load(audio_file)
|
|
|
52 |
output_files = []
|
53 |
for i in range(ests_speech.shape[0]):
|
54 |
path = os.path.join(output_dir, f"speaker_{i+1}.wav")
|
55 |
+
waveform = ests_speech[i].unsqueeze(0).cpu() # shape: (1, samples)
|
56 |
+
torchaudio.save(path, waveform, TARGET_SR) # Saves as valid WAV
|
57 |
output_files.append(path)
|
58 |
|
59 |
return output_files
|
60 |
|
61 |
|
62 |
+
|
63 |
@spaces.GPU()
|
64 |
def separate_dnr(audio_file):
|
65 |
audio, sr = torchaudio.load(audio_file)
|