Spaces:
Running
on
Zero
Running
on
Zero
use soudfile for speaker sep audio saving
Browse files- gradio_app.py +3 -1
gradio_app.py
CHANGED
@@ -3,6 +3,7 @@ import uuid
|
|
3 |
import torch
|
4 |
import torchaudio
|
5 |
import torchaudio.transforms as T
|
|
|
6 |
import gradio as gr
|
7 |
import look2hear.models
|
8 |
|
@@ -65,7 +66,8 @@ def separate_speakers(audio_path):
|
|
65 |
output_files = []
|
66 |
for i in range(ests_speech.shape[0]):
|
67 |
path = os.path.join(output_dir, f"speaker_{i+1}.wav")
|
68 |
-
|
|
|
69 |
output_files.append(path)
|
70 |
|
71 |
updates = []
|
|
|
3 |
import torch
|
4 |
import torchaudio
|
5 |
import torchaudio.transforms as T
|
6 |
+
import soundfile as sf
|
7 |
import gradio as gr
|
8 |
import look2hear.models
|
9 |
|
|
|
66 |
output_files = []
|
67 |
for i in range(ests_speech.shape[0]):
|
68 |
path = os.path.join(output_dir, f"speaker_{i+1}.wav")
|
69 |
+
audio_np = ests_speech[i].cpu().numpy()
|
70 |
+
sf.write(path, audio_np.T, TARGET_SR) # Transpose only if shape is [T, C], usually not needed
|
71 |
output_files.append(path)
|
72 |
|
73 |
updates = []
|