Skip to content

Add optional TwelveLabs Pegasus transcription engine#18

Open
mohit-twelvelabs wants to merge 1 commit into
NullMagic2:mainfrom
mohit-twelvelabs:feat/twelvelabs-integration
Open

Add optional TwelveLabs Pegasus transcription engine#18
mohit-twelvelabs wants to merge 1 commit into
NullMagic2:mainfrom
mohit-twelvelabs:feat/twelvelabs-integration

Conversation

@mohit-twelvelabs

Copy link
Copy Markdown

Hi! I'm Mohit, I work at TwelveLabs (@mohit-twelvelabs).

This PR adds an opt-in cloud transcription engine powered by the TwelveLabs Pegasus video-understanding model, alongside the existing local Whisper.cpp engine.

What it adds

  • A new Engine dropdown in Optional Settings with two choices: whisper.cpp (default) and twelvelabs-pegasus.
  • A small twelvelabs_backend.py module that uploads the selected media as a TwelveLabs asset, runs Pegasus analysis, and returns the exact same result dict shape as transcribe_audio() (raw / text / segments / audio_length / stderr / cancelled). Because of this, SRT export, diarization, and the transcript display all work unchanged.
  • A TwelveLabs API key field (also read from the TWELVELABS_API_KEY environment variable), persisted in config.json like the other settings.

Why it helps

Whisper.cpp is great for local, offline transcription. Pegasus gives users an optional cloud path that handles long videos and runs without needing a local model or GPU — useful when the machine can't run the larger Whisper models comfortably.

Opt-in / non-breaking

The default engine stays whisper.cpp and that code path is untouched. The TwelveLabs code only runs when a user explicitly selects the new engine. The dependency (twelvelabs>=1.2.8) is only imported lazily inside the backend, so existing installs are unaffected until they opt in.

How it was tested

  • python -m unittest test_twelvelabs_backend — offline unit tests for the timestamp/segment parsers, result-shape contract, and API-key resolution (added in this PR; they run without a key).
  • A live smoke test (gated on TWELVELABS_API_KEY, skipped otherwise) confirming the client constructs and the analyze/assets API is wired correctly.
  • Verified against the real API with my key: client authenticates and a TwelveLabs embedding call returns a 512-dim vector. The Pegasus request wiring is verified against the installed SDK (asset upload + VideoContext_AssetId + analyze); a full end-to-end Pegasus run is slow due to server-side video processing.
  • py_compile on all changed files.

You can grab a free API key at https://twelvelabs.io — there's a generous free tier.

Add an opt-in cloud transcription backend using the TwelveLabs Pegasus
model alongside the default local Whisper.cpp engine. Select it from the
new Engine dropdown in Optional Settings; the default behavior is
unchanged. The backend returns the same result shape as transcribe_audio,
so SRT export, diarization, and display all work unchanged. API key is
read from the TWELVELABS_API_KEY env var or the settings field.
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