Skip to content

fix(transcription): repair AssemblyAI deprecation, add providers, harden upload/YouTube crashes#73

Open
steethebutcher wants to merge 1 commit into
FujiwaraChoki:mainfrom
steethebutcher:fix/transcription-and-youtube-crash
Open

fix(transcription): repair AssemblyAI deprecation, add providers, harden upload/YouTube crashes#73
steethebutcher wants to merge 1 commit into
FujiwaraChoki:mainfrom
steethebutcher:fix/transcription-and-youtube-crash

Conversation

@steethebutcher

Copy link
Copy Markdown

Summary

Fixes transcription crashes from the deprecated AssemblyAI speech_model parameter, integrates multiple transcription providers, hardens several YouTube/upload crash paths, and raises the local-upload size limit so large files actually upload.

Background & PR review

Reviewed the open PRs targeting the transcription/AssemblyAI area. Several attempt the same fix but none merge cleanly (all target a pre-#63 base before the _assemblyai_speech_model_value refactor), so the logic was ported onto current main:

Changes

1. AssemblyAI deprecation fix (video_utils.py)

AssemblyAI deprecated the singular speech_model (best/nano/universal) server-side; requests now require the plural speech_models list (universal-3-pro, universal-2). Replaced _assemblyai_speech_model_value_assemblyai_speech_models_value, mapping legacy aliases: nano/universal-2["universal-2"]; everything else → ["universal-3-pro", "universal-2"].

2. Transcription provider choice (TRANSCRIPTION_PROVIDER)

New config: assemblyai (default) | whisper | youtube_captions.

  • Local Whisper with word-level timestamps; Whisper seconds are converted to ms to match the transcript-cache units so subtitles align.
  • YouTube-captions extraction via yt-dlp.
  • cache_transcript_data, format_transcript_for_analysis, _serialize_transcript_word are now polymorphic (AssemblyAI objects + Whisper dicts).
  • generate_transcript now threads source_url so the youtube_captions provider works.

3. Local upload size limit (the large-upload bug)

The frontend cap was raised to 12 GB but the backend still hardcoded 1 GB, so large uploads hit POST /upload and were rejected with HTTP 413. Made the limit configurable (MAX_VIDEO_UPLOAD_BYTES, default 12 GB) and fixed stale "under 1 GB" client messages.

4. Connection-pool exhaustion (#50)

get_clip_file / export_clip held the Depends(get_db) session open for the whole FileResponse/ffmpeg export → "idle in transaction" → QueuePool exhaustion under normal playback. Added await db.close() after the clip lookup in both routes, plus an idle_in_transaction_session_timeout safety net on the engine.

5. YouTube/download crash hardening

  • Downloaded source videos were never cleaned up → disk fills → silent crashes. Now cleaned on both success and error paths (uses the previously-dead cleanup_downloaded_files).
  • Tasks that died mid-"processing" were stuck forever (only "queued" stale tasks were recovered). Added _is_stale_processing_task + PROCESSING_TASK_TIMEOUT_SECONDS (default 4h, safely above arq's 3h job_timeout).

Env / config impact

New optional env vars (all have safe defaults, backward compatible):

  • TRANSCRIPTION_PROVIDER (default assemblyai)
  • MAX_VIDEO_UPLOAD_BYTES (default 12000000000)
  • PROCESSING_TASK_TIMEOUT_SECONDS (default 14400)

No DB migrations.

Verification

  • python -m compileall src clean; all edited modules import without cycles.
  • Backend tests: 103 passed, 9 skipped. Added 4 new tests (AssemblyAI speech_models mapping, Whisper provider dispatch, Whisper-dict formatting & caching).
  • The 1 failing test (test_burn_ass_subtitles_passes_selected_fonts_dir) is pre-existing on clean main — a Windows path-escaping artifact in an ffmpeg filter, unrelated to this change.

Manual verification steps

  • TRANSCRIPTION_PROVIDER=assemblyai: confirm speech_models request succeeds (no more deprecation 400).
  • TRANSCRIPTION_PROVIDER=whisper: short video transcribes locally, subtitles align.
  • Upload a >1 GB file: succeeds (was: HTTP 413).
  • Play/export a clip under concurrent load: no "idle in transaction" pile-up.

…den upload/YouTube crashes

- AssemblyAI: switch deprecated singular speech_model to plural speech_models
  list (universal-3-pro/universal-2); legacy aliases mapped (ports FujiwaraChoki#47)
- Transcription: add TRANSCRIPTION_PROVIDER (assemblyai|whisper|youtube_captions)
  with local Whisper word-timestamps and YouTube caption extraction (ports FujiwaraChoki#55)
- Upload: raise backend size limit to configurable MAX_VIDEO_UPLOAD_BYTES
  (default 12 GB); frontend was 12 GB but backend still hardcoded 1 GB -> HTTP 413
- DB pool: release Depends(get_db) session before FileResponse/ffmpeg export in
  clip file/export routes + idle_in_transaction_session_timeout safety net (FujiwaraChoki#50)
- YouTube crash: clean up downloaded source videos on success/error paths;
  recover tasks stuck in "processing" via PROCESSING_TASK_TIMEOUT_SECONDS
- Tests: +4 (speech_models mapping, whisper dispatch, whisper-dict format/cache)
@vercel

vercel Bot commented Jul 3, 2026

Copy link
Copy Markdown

@steethebutcher is attempting to deploy a commit to the Shiori LLC Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant