Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -151,8 +151,11 @@ 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 |
|
|
@@ -676,7 +679,6 @@ try:
|
|
| 676 |
|
| 677 |
current_renames = st.session_state.speakerRenames[currFileIndex]
|
| 678 |
for sp in speakerNames:
|
| 679 |
-
# Read the live widget value so label updates immediately on rename
|
| 680 |
widget_key = f"rename_{currFileIndex}_{sp}"
|
| 681 |
live_name = st.session_state.get(widget_key, "").strip()
|
| 682 |
display_label = live_name if live_name else current_renames.get(sp, sp)
|
|
|
|
| 151 |
|
| 152 |
clip_waveform = waveform[:, start_sample:end_sample]
|
| 153 |
|
| 154 |
+
# soundfile has no FFmpeg/torchcodec dependency
|
| 155 |
+
import soundfile as sf
|
| 156 |
+
clip_np = clip_waveform.numpy().T # (channels, samples) -> (samples, channels)
|
| 157 |
buffer = io.BytesIO()
|
| 158 |
+
sf.write(buffer, clip_np, sample_rate, format="WAV", subtype="PCM_16")
|
| 159 |
buffer.seek(0)
|
| 160 |
clips[speaker] = buffer.read()
|
| 161 |
|
|
|
|
| 679 |
|
| 680 |
current_renames = st.session_state.speakerRenames[currFileIndex]
|
| 681 |
for sp in speakerNames:
|
|
|
|
| 682 |
widget_key = f"rename_{currFileIndex}_{sp}"
|
| 683 |
live_name = st.session_state.get(widget_key, "").strip()
|
| 684 |
display_label = live_name if live_name else current_renames.get(sp, sp)
|