Add error detail logging for ASR failures

This commit is contained in:
2026-03-24 01:27:51 +00:00
parent eecd8944e4
commit e9a2fdfcfc

View File

@@ -115,7 +115,18 @@ def transcribe_chunk_fish(chunk_path, api_key, start_offset_sec):
with Session(api_key) as session:
with open(chunk_path, "rb") as f:
result = session.asr(ASRRequest(audio=f.read(), language="en"))
audio_bytes = f.read()
print(f" Sending {len(audio_bytes)/1024/1024:.1f}MB to Fish Audio...", flush=True)
try:
result = session.asr(ASRRequest(audio=audio_bytes, language="en"))
except Exception as e:
# Try to get more detail on the error
resp = getattr(e, 'response', None) or getattr(e, '__cause__', None)
if resp is not None:
status = getattr(resp, 'status_code', '?')
body = getattr(resp, 'text', getattr(resp, 'content', b''))
raise RuntimeError(f"Fish Audio ASR failed: HTTP {status}{body}") from e
raise
# Fish Audio returns timestamps in milliseconds — convert to seconds
# and adjust by the chunk's start offset in the full audio