Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,8 +151,12 @@ def generate_speaker_clips(annotations, waveform, sample_rate, file_index):
|
|
| 151 |
|
| 152 |
clip_waveform = waveform[:, start_sample:end_sample]
|
| 153 |
|
|
|
|
|
|
|
|
|
|
| 154 |
buffer = io.BytesIO()
|
| 155 |
-
|
|
|
|
| 156 |
buffer.seek(0)
|
| 157 |
clips[speaker] = buffer.read()
|
| 158 |
|
|
|
|
| 151 |
|
| 152 |
clip_waveform = waveform[:, start_sample:end_sample]
|
| 153 |
|
| 154 |
+
# Use soundfile (pure C, no FFmpeg/torchcodec) to encode WAV bytes
|
| 155 |
+
# soundfile expects (samples, channels) numpy array; waveform is (channels, samples) tensor
|
| 156 |
+
clip_np = clip_waveform.numpy().T
|
| 157 |
buffer = io.BytesIO()
|
| 158 |
+
import soundfile as sf
|
| 159 |
+
sf.write(buffer, clip_np, sample_rate, format="WAV", subtype="PCM_16")
|
| 160 |
buffer.seek(0)
|
| 161 |
clips[speaker] = buffer.read()
|
| 162 |
|