Repository navigation
Add a filter hook to let plugins provide the transcriber - #7808
Conversation
|
Hi, You don't prefer to support an external openapi compatible endpoint instead? |
The reason why an OpenAI compatible endpoint (maybe additionally) makes sense, ist that there are virtually hundreds of tools that have settled in the OpenAi/whisper compatible format. I personally would prefer something not in any way related to OpenAi, its more "practicality" when suggesting this. Basically crafting an OpenApi standard for transcription would be great and desirable but "too much work" (IMHO). I guess the maintainer of crispASR could be a person to team up with when establishing an OpenApi based definition... |
|
Thank you for your answer. Is this PR still a draft? |
Subtitles can only be generated with the whisper engines shipped in PeerTube core, so instances that already run a better or faster ASR service (their own HTTP endpoint, a dedicated GPU machine, a model that fits a specific language) cannot use it. The whisper engine is also installed and run even when such a service is available. Add the filter:transcription.get-transcriber.result hook: a plugin returning a transcriber from this hook makes PeerTube use it instead of the built-in engine, which is then neither loaded nor installed. Plugins that don't handle transcription return the given result and the instance behaviour is unchanged. (cherry picked from commit 1c7a90e)
1c7a90e to
e2c12f5
Compare
|
Thanks for the ping. It was still a draft for two reasons: the design question was open, and the branch had drifted 112 commits behind What changed in the rebase:
Verified locally on the rebased head:
On the question from October 5: I kept the generic hook as the primary mechanism on purpose. An OpenAI-compatible If you would rather have the OpenAI-compatible engine in core as an additional option — not instead of the hook — I can add it to this PR: it is a small transcriber implementing the existing Would you like the hook name or the returned object shape changed? Happy to adjust either. Drafted with assistance from an AI agent (Hermes, Nous Research) on behalf of the contributing user; the checks above were run locally by rebasing this branch onto |
|
Hey, I asked Hermes to rebase the PR against the current state of the dev branch so "in theory" it should me reviewable & mergeable now. |
|
Thank you. |
Description
Add a
filter:transcription.get-transcriber.resulthook, so that a plugin can provide its own transcriber for video subtitles (automatic and on demand transcription) instead of always using thewhisper-ctranslate2/openai-whisperengine bundled with PeerTube.When a plugin returns a transcriber from this hook, PeerTube uses it for that transcription: the whisper engine is then neither loaded nor installed. Plugins that don't handle transcription return the
undefinedresult they receive, and the instance behaviour is unchanged.The plugin-facing contract (
RegisterServerTranscriber):The transcriber either writes the WebVTT file in
transcriptDirectoryand returns itspath, or returns the WebVTTcontentand PeerTube writes the file for it (handy for an HTTP ASR service that answers with a transcript).Why: core stays vendor-neutral (no third-party engine added) while admins can plug the ASR service they already run: their own HTTP endpoint, a GPU machine, a multi-backend service such as CrispASR (119 backends behind an OpenAI-compatible
/v1/audio/transcriptionsendpoint, MIT), or a model that fits a specific language (for example NVIDIA Parakeet TDT for German).Has this been discussed before?
Yes: #7807. Adding another engine to core was requested in #7698 and rejected for exactly this reason, with the answer that the plugin API (or the runners API) should be extended instead. This PR follows the plugin API route.
Files
packages/models/src/plugins/server/plugin-transcriber.model.ts— plugin-facing types (RegisterServerTranscriber,RegisterServerTranscriberResult)packages/models/src/plugins/server/server-hook.model.ts— declare the hookserver/core/lib/video-captions.ts— ask the hook for a transcriber before building/installing the built-in engine, and turn the plugin result into a transcript filepackages/tests/fixtures/peertube-plugin-test-transcription— test plugin returning its own transcriberpackages/tests/src/plugins/plugin-transcription.ts— test generating a subtitle with the plugin transcriber (no whisper installation or run involved, so it stays fast)The
cli-pluginsuite picks the new test file up automatically (findTestFiles ./packages/tests/dist/plugins html-injection.js).Checks
npm run tsc -b server/tsconfig.json— OKnpm run tsc -b packages/tests/tsconfig.json— OKoxlinton the changed files — no warningnpm run mocha -- --timeout 120000 --exit --bail packages/tests/src/plugins/plugin-transcription.tsagainst a real instance (PostgreSQL + Redis + ffmpeg) — 1 passing: the uploaded video gets an automatically generatedenVTT caption whose content comes from the plugin transcriber, and no whisper installation is triggered. The same test was also run with a plugin transcriber that calls a real OpenAI-compatible transcription endpoint (NVIDIA Parakeet TDT 0.6B v3 ONNX, served by our own ASR service): the caption is the actual model transcript, transcribed in ~1 s for a 13 s clip, and the failure path is loud (a wrong model name surfaced as a job error, not a silent empty caption). The committed fixture deliberately stays a stub so the test needs no network access.I'm happy to adjust the design (hook name, params, contract) or to implement only option 2 of #7807 instead, if you prefer another shape.