Bharti Subtitles

Description

Pick a video in your Media Library, press one button, and get a subtitle file
attached to it. Visitors then see a subtitles button on the video player.

The speech-to-text runs in the browser, on the machine of whoever pressed
the button. Not on your server, and not on anyone’s API. That single decision
is what this plugin is, and everything below follows from it.

Nothing leaves the computer

There are two ways to turn speech into text: send the audio somewhere and get
the words back, or run the model where the audio already is. This plugin does
the second.

For a marketing clip either way is fine. For patient education, legal
recordings, internal training, HR material or paid membership content, sending
the file to a third party is often the difference between allowed and not
allowed
.

The browser reads the file, works on it, and writes the result back. The only
thing that ever downloads is the speech model itself, once.

No account, no key, no bill

  • Nothing to sign up for. No OpenAI account, no API key to create, store,
    rotate or explain to a client.
  • No per-minute charge. Transcription services meter audio by the minute.
    Nothing here is metered — caption the same course twice, or a hundred hours
    of it, and the cost does not change.
  • No server load. Your host never transcodes or transcribes anything, so
    this runs on the cheapest shared hosting without a queue, a cron job or a
    worker process.

How it works

  1. Go to Media > Bharti Subtitles, choose a video and the spoken language, press
    Generate subtitles
  2. Watch the lines appear, then fix anything the model misheard — names and
    technical words are usually where it slips
  3. Press Save to this video. The .vtt is written beside the video and
    attached to it

Or download .srt / .vtt instead and take it to YouTube, Vimeo or a video
editor.

What you get

  • 17 languages, including Hindi, Marathi and Hinglish written in Roman
    script
  • Every line editable before you save
  • Works with the Gutenberg Video block and the classic [video] shortcode
  • Control how the subtitles look — font, size, bold, capitals, colour,
    background and opacity, shadow, position and alignment — with a live preview
  • Translation ready, with a .pot file included

Accessibility

Captions for prerecorded video are a WCAG 2.1 requirement (Success Criterion
1.2.2). If your site has an accessibility obligation, this is one of the items
on the list.

Honest limits

Most of this would normally be left out of a plugin page. It is here because
the wrong expectation wastes your time and mine.

  • The first run downloads the speech model — about 50 MB for most
    languages, about 250 MB for Hindi, Marathi and Hinglish, which need a larger
    one. The browser keeps it, so it is once per machine, not once per video.
  • Speed depends on the machine, not the hosting. A modern laptop manages
    roughly real time or better. An old one will be slower.
  • No bulk or overnight processing. One video at a time, with a browser tab
    open. Doing it in bulk would mean a server doing the work, and then the zero
    cost and the privacy both disappear.
  • Hindi, Marathi and Hinglish need more correcting than English. The model
    has seen far less of them. What you get is a usable draft to fix, which is
    much faster than typing from nothing — but it is a draft, and the panel says
    so before you press the button.
  • The video must be one your browser can play. MP4 (H.264 + AAC) and WebM
    are safest. HEVC inside a .mov will not decode.

What it needs

  • A current version of Chrome, Edge, Firefox or Safari
  • An internet connection the first time, to download the speech model
  • A writable uploads folder — the .vtt is saved beside the video

Source code and build

The two files in assets/js/ are built, not written by hand. Their complete
source ships inside this plugin so nothing needs to be taken on trust:

  • src/ — all of the TypeScript and React that becomes them
  • package.json, tsconfig.json, vite.config.ts, vite.worker.config.ts
    the build configuration

To rebuild from that source:

npm install
npm run build

which regenerates assets/js/subtitles.js and
assets/js/transcribe-worker.js exactly as shipped.

Third-party code

Bundled into those two files by the build, both unmodified:

  • React 18.3 — https://github.com/facebook/react — MIT
  • Transformers.js 3.8.1 — https://github.com/huggingface/transformers.js —
    Apache-2.0

External services

Two things are downloaded into the browser the first time you generate
subtitles, and then kept by the browser’s cache. Nothing is uploaded, no
account is needed, and no key is required.

The speech engine

  • What: ONNX Runtime Web, the WebAssembly engine that runs the model.
    Part of Transformers.js, pinned to version 3.8.1.
  • Server: jsDelivr — https://cdn.jsdelivr.net/npm/@huggingface/transformers@3.8.1/dist/
  • When: the first time you press Generate subtitles, once per browser.
  • Sent: nothing. It is a download.

The speech model

  • What: an OpenAI Whisper model, converted for the browser. About 50 MB
    for most languages, about 250 MB for Hindi, Marathi and Hinglish.
  • Server: Hugging Face — https://huggingface.co/
  • When: the first time you use a given language, once per browser.
  • Sent: nothing. It is a download.

Your video is never sent to either of them, or to anywhere else. It is read
from your own Media Library by your own browser and worked on there.

Terms and privacy: jsDelivr — https://www.jsdelivr.com/terms and
https://www.jsdelivr.com/terms/privacy-policy-jsdelivr-net · Hugging Face —
https://huggingface.co/terms-of-service and https://huggingface.co/privacy

Serving them yourself

If your site cannot reach an outside server — some government, medical and
internal deployments cannot, and jsDelivr is blocked in some countries — put
the files on your own host and point the plugin at them:

add_filter( 'bharti_subtitles_wasm_paths', function () {
    return 'https://example.com/onnx/'; 
} );

The files to copy are the contents of @huggingface/transformers@3.8.1/dist/.
The model can be self-hosted the same way; see the Transformers.js
documentation for env.remoteHost.

Be honest with yourself about this before installing: if the first run cannot
reach these two servers, the plugin cannot generate subtitles. After that
first run it works offline.

Screenshots

Installation

  1. Upload the plugin folder to /wp-content/plugins/, or install the ZIP through Plugins > Add New > Upload Plugin.
  2. Activate it.
  3. Go to Media > Bharti Subtitles.
  4. Pick a video, pick the spoken language, press Generate subtitles.
  5. Check the lines, fix anything the model misheard, then Save to this video.

Defaults live under Settings > Bharti Subtitles.

FAQ

Do I need an OpenAI key or any other account?

No. Nothing is sent to any API. The model runs inside your own browser.

Is my video uploaded anywhere?

No. The browser reads the file straight from your own Media Library and works
on it locally. The only thing downloaded is the speech model itself, once.

Why is the first run slow?

The speech model has to be downloaded the first time — about 50 MB for most
languages, about 250 MB for Hindi, Marathi and Hinglish, which need a larger
one. After that the browser has it and there is no wait. Transcription speed
then depends on the machine, not on your hosting — a modern laptop does roughly
real time or better.

Can I run it on the server instead, or in bulk overnight?

Not in this version. Everything is deliberately in the browser, which is what
keeps the cost at zero and the video private. Bulk generation would mean a
server doing the work, and that means both of those go away.

The subtitles do not show on the front end.

Check three things: the video has subtitles saved (Media > Bharti Subtitles will say
so), Settings > Bharti Subtitles > “Automatically show subtitles” is on, and your
theme is not replacing the video player with its own. If it is, turn the
setting off and add the track yourself.

The subtitles show, but there is no CC button.

The Video block has Playback controls switched off, so the player draws no
controls at all. Select the video in the editor and turn that setting on.
Nothing is wrong with the subtitles — they are attached, which is why they
appear on screen.

It says the browser could not read the audio.

The video is in a codec your browser will not decode — usually HEVC inside a
.mov. Convert it to MP4 (H.264 + AAC), re-upload, and it will work.

Which languages work?

English, Spanish, French, German, Italian, Portuguese, Dutch, Russian, Polish,
Japanese, Korean, Chinese, Turkish and Indonesian are the strong ones. Hindi,
Marathi and Hinglish also work, with two honest caveats below. Only languages
the on-device model actually handles are offered — listing more would just
produce bad subtitles.

What is different about Hindi, Marathi and Hinglish?

Two things, and the panel tells you both before you press the button.

They need the larger speech model — about 250 MB instead of 50 MB, and slower
to run. The smaller model does not write these languages down at all: it turns
Hindi into English and Marathi into Roman letters, so the size buys the script
itself.

And be realistic about the accuracy. The model has seen far less of these
languages than of English, and on a Marathi test most lines came back with
the script correct but the words wrong — close enough to recognise what was
said, not close enough to publish. Expect to rewrite most of them.

What is reliably right is the timing. The tedious half of subtitling is
deciding which line shows when, and that comes out correct: fourteen cues,
each three or four seconds, following the speech. Retyping the words into a
finished set of cues is still much faster than building the whole thing from
nothing — but that is what you are getting, not a draft you lightly correct.

English and the European languages do not have this problem.

Does it work on mobile?

The panel is for site owners, so it is built for a desktop browser. The
subtitles it produces show on every device, mobile included.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“Bharti Subtitles” is open source software. The following people have contributed to this plugin.

Contributors

Translate “Bharti Subtitles” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

1.0.0

  • First release.