Spaces:
Paused
Paused
Malina Claude Opus 5 (1M context) commited on
Commit ·
3b71b6c
1
Parent(s): ac0c9e0
Film bez sciezki dzwiekowej przestaje wywracac cala analize
Browse filesKontener bez audio wysadzal odczyt: PyAV rzuca IndexError w srodku
faster_whisper, kiedy prosi o strumien audio numer 0 w pliku, ktory go nie ma.
Wyjatek szedl do slownika i ginal, a uzytkownik dostawal "Error reading video."
w jedna sekunde. Zmierzone na zwyklym H.264 bez audio: kazda analiza takiego
pliku konczyla sie tak samo, czyli nagranie ekranu bez narracji, najbardziej
naturalny przypadek uzycia dla tego narzedzia, nie dzialalo w ogole.
Brak dzwieku to teraz cisza, a nie blad: load_audio zwraca pusta fale, Whisper
nie jest w ogole wolany, a synteza idzie sciezka wizualna, ktora ten kod od
poczatku deklarowal ("No speech is fine").
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- audio.py +17 -2
- pipeline.py +4 -1
audio.py
CHANGED
|
@@ -14,8 +14,23 @@ from utils import fmt_time
|
|
| 14 |
|
| 15 |
|
| 16 |
def load_audio(media_path: str) -> np.ndarray:
|
| 17 |
-
"""Decode any container to float32 mono 16 kHz waveform (PyAV, no temp file).
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
|
| 21 |
def media_duration(media_path: str) -> float:
|
|
|
|
| 14 |
|
| 15 |
|
| 16 |
def load_audio(media_path: str) -> np.ndarray:
|
| 17 |
+
"""Decode any container to float32 mono 16 kHz waveform (PyAV, no temp file).
|
| 18 |
+
|
| 19 |
+
A file with NO audio stream comes back as silence rather than an exception. PyAV
|
| 20 |
+
raises IndexError deep inside faster_whisper when it asks for audio stream 0 of a
|
| 21 |
+
container that has none, and that exception used to take the whole ingest down:
|
| 22 |
+
every silent clip answered "Error reading video." in about a second, with the
|
| 23 |
+
reason swallowed. Measured on a plain H.264 file with no audio track, 2026-09-21.
|
| 24 |
+
|
| 25 |
+
Silence is the honest input here. The pipeline already handles "no speech" and
|
| 26 |
+
falls back to visual-only synthesis, which is exactly what a screen recording
|
| 27 |
+
without narration needs."""
|
| 28 |
+
try:
|
| 29 |
+
return decode_audio(media_path, sampling_rate=SAMPLE_RATE)
|
| 30 |
+
except (IndexError, StopIteration):
|
| 31 |
+
print(f"[NINA] no audio stream in {str(media_path).split('/')[-1]}, "
|
| 32 |
+
f"continuing from the picture alone", flush=True)
|
| 33 |
+
return np.zeros(0, dtype=np.float32)
|
| 34 |
|
| 35 |
|
| 36 |
def media_duration(media_path: str) -> float:
|
pipeline.py
CHANGED
|
@@ -100,7 +100,10 @@ def ingest_video(video_path: str, stage: "_Stage | None" = None) -> dict:
|
|
| 100 |
# WHISPER fast pass, then a fallback ladder when it looks unreliable:
|
| 101 |
# 1. a clean embedded subtitle track (best, if the file has one), else
|
| 102 |
# 2. vocal isolation + re-transcription (pull the voice out of the music).
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
| 104 |
if segments:
|
| 105 |
rel = transcript_reliability(segments)
|
| 106 |
if not rel["reliable"]:
|
|
|
|
| 100 |
# WHISPER fast pass, then a fallback ladder when it looks unreliable:
|
| 101 |
# 1. a clean embedded subtitle track (best, if the file has one), else
|
| 102 |
# 2. vocal isolation + re-transcription (pull the voice out of the music).
|
| 103 |
+
# No waveform at all means the container had no audio stream. Whisper has
|
| 104 |
+
# nothing to do with an empty array, and asking it anyway is how a silent
|
| 105 |
+
# screen recording turns into a failed build.
|
| 106 |
+
segments = transcribe_fast(audio) if getattr(audio, "size", 0) else []
|
| 107 |
if segments:
|
| 108 |
rel = transcript_reliability(segments)
|
| 109 |
if not rel["reliable"]:
|