forced-aligner / index.html
CiscoR's picture
In-browser forced aligner (transformers.js, int8 ONNX)
33af36b verified
Raw History Blame Contribute Delete
12.6 kB
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Forced Aligner · Cis Labs</title>
<meta name="description" content="Word-level timestamps and subtitles for audio you already have a transcript for, in native scripts. A multilingual CTC aligner that runs entirely in your browser.">
<link rel="stylesheet" href="style.css">
<script type="module" src="app.js"></script>
</head>
<body>
<main class="wrap">
<header class="hero">
<p class="brand"><a href="https://huggingface.co/Cis-Labs" target="_blank" rel="noopener">Cis Labs</a></p>
<h1>Forced Aligner</h1>
<p class="lede">Word-level timestamps for audio you already have a transcript for, in native scripts, from a
model trained on 1,600+ languages. Get subtitles, karaoke-style highlighting and precise cut points, then use
the same model in your ctc-forced-aligner or WhisperX pipeline.</p>
<ul class="pills">
<li>Multilingual</li><li>Native scripts</li><li>Apache-2.0</li>
<li>Drop-in for ctc-forced-aligner &amp; WhisperX</li><li class="hl">Runs in your browser</li>
</ul>
<p class="links">
<a id="model-link" href="https://huggingface.co/Cis-Labs/omniasr-ctc-300m-forced-aligner" target="_blank" rel="noopener">Model card</a><span class="sep">·</span>
<a href="https://github.com/Cis-Labs-Hub/forced-aligner" target="_blank" rel="noopener">Conversion &amp; evals</a><span class="sep">·</span>
<a href="https://huggingface.co/Cis-Labs" target="_blank" rel="noopener">Cis Labs on Hugging Face</a>
</p>
</header>
<section class="status" id="status" data-state="loading" aria-live="polite">
<div class="status-main"><span class="dot" aria-hidden="true"></span><span id="status-text">Starting…</span></div>
<span id="status-detail"></span>
<div class="bar" aria-hidden="true"><div id="bar-fill"></div></div>
<button id="load-btn" type="button" hidden>Load model</button>
<span class="privacy">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg>
Runs entirely in your browser. Your audio never leaves this page.
</span>
</section>
<div class="grid">
<section class="panel inputs" aria-label="Inputs">
<div class="label-row"><span class="label" id="audio-label">Audio <small>(up to 3 minutes)</small></span>
<span class="hint" id="audio-name"></span></div>
<div class="drop" id="drop" aria-labelledby="audio-label">
<input type="file" id="file" accept="audio/*,video/webm,video/mp4,.flac,.m4a,.opus,.ogg,.wav,.mp3,.webm" hidden>
<button type="button" class="ghost big" id="pick">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 16V4m0 0-5 5m5-5 5 5"/><path d="M4 16v3a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-3"/></svg>
Upload audio</button>
<button type="button" class="ghost big" id="record">
<span class="rec-dot" aria-hidden="true"></span><span id="record-text">Record</span></button>
<span class="drop-hint">or drop a file here · WAV, FLAC, MP3, OGG, M4A, WebM</span>
</div>
<div class="label-row"><label class="label" for="transcript">Transcript</label>
<span class="hint" id="input-hint">Ctrl / ⌘ + Enter to align</span></div>
<textarea id="transcript" rows="6" maxlength="12000" spellcheck="false"
placeholder="Exactly what is said in the audio. Punctuation and capitalization are fine."></textarea>
<div class="row2">
<div>
<label class="label" for="lang">Language <small>(ISO 639-3)</small></label>
<input id="lang" list="langs" value="eng" autocomplete="off" spellcheck="false">
<datalist id="langs"></datalist>
<p class="hint">Pick one or type any code, e.g. swh, kin, quy</p>
</div>
<div>
<span class="label" id="gran-label">Granularity</span>
<div class="seg" role="radiogroup" aria-labelledby="gran-label">
<label><input type="radio" name="gran" value="words" checked><span>Words</span></label>
<label><input type="radio" name="gran" value="characters"><span>Characters</span></label>
</div>
<p class="hint">Characters for Chinese and Japanese</p>
</div>
</div>
<details class="opts">
<summary>Subtitle and alignment options</summary>
<div class="opt">
<span class="label" id="cue-label">SRT cues</span>
<div class="seg" role="radiogroup" aria-labelledby="cue-label">
<label><input type="radio" name="cue" value="lines" checked><span>Lines</span></label>
<label><input type="radio" name="cue" value="words"><span>One word per cue</span></label>
</div>
</div>
<div class="opt">
<div class="label-row tight"><label class="label" for="max-chars">Max characters per line</label><output id="max-chars-out" for="max-chars">42</output></div>
<input type="range" id="max-chars" min="16" max="84" step="1" value="42">
<p class="hint">Cues also break at sentence ends and pauses &gt; 0.6 s</p>
</div>
<label class="check"><input type="checkbox" id="separators" checked>
<span>Word separators <small>Insert the model's word separator between words. Off reproduces
ctc-forced-aligner's CLI output exactly.</small></span></label>
</details>
<button id="run" class="primary" type="button" disabled>Align</button>
<div class="examples" id="examples"><span class="mini">Examples</span></div>
</section>
<section class="panel outputs" aria-label="Results">
<div class="label-row"><span class="label">Timeline</span>
<span class="downloads">
<a class="ghost btn" id="dl-srt" download aria-disabled="true">SRT</a>
<a class="ghost btn" id="dl-json" download aria-disabled="true">JSON</a>
</span></div>
<div id="player" class="player">
<audio id="audio" controls preload="auto"></audio>
<div class="timeline" id="timeline" title="Click to seek"><div class="head" id="head"></div></div>
<div class="words" id="words" dir="auto"></div>
<div class="legend">Click any word to play from there.
<span class="key ok"></span>confident <span class="key mid"></span>uncertain
<span class="key lo"></span>low: check the transcript</div>
</div>
<div class="notes" id="notes"></div>
</section>
</div>
<section class="panel" aria-labelledby="table-label">
<div class="label-row"><span id="table-label" class="label">Word timestamps</span>
<button id="copy-table" class="ghost" type="button">Copy as TSV</button></div>
<div class="table-wrap">
<table id="table">
<thead><tr><th>#</th><th>Word</th><th>Start (s)</th><th>End (s)</th><th>Score</th></tr></thead>
<tbody></tbody>
</table>
</div>
</section>
<section class="panel code" aria-labelledby="code-label">
<h2 id="code-label">Use it in your pipeline</h2>
<p>The model is a one-string drop-in: pass <code>Cis-Labs/omniasr-ctc-300m-forced-aligner</code> as the alignment
model. Snippets follow the language and granularity selected above.</p>
<div class="tabs" role="tablist">
<button class="tab" role="tab" id="tab-cfa" aria-selected="true" aria-controls="pane-cfa" type="button">ctc-forced-aligner</button>
<button class="tab" role="tab" id="tab-wx" aria-selected="false" aria-controls="pane-wx" type="button">WhisperX</button>
<button class="tab" role="tab" id="tab-js" aria-selected="false" aria-controls="pane-js" type="button">JavaScript</button>
</div>
<div class="tabpane" role="tabpanel" id="pane-cfa" aria-labelledby="tab-cfa">
<p class="sub">CLI</p>
<div class="codebox"><button class="ghost copy-code" type="button" data-target="code-cfa-cli">Copy</button><pre><code id="code-cfa-cli"></code></pre></div>
<p class="sub">Python</p>
<div class="codebox"><button class="ghost copy-code" type="button" data-target="code-cfa-py">Copy</button><pre><code id="code-cfa-py"></code></pre></div>
</div>
<div class="tabpane" role="tabpanel" id="pane-wx" aria-labelledby="tab-wx" hidden>
<p class="sub">CLI</p>
<div class="codebox"><button class="ghost copy-code" type="button" data-target="code-wx-cli">Copy</button><pre><code id="code-wx-cli"></code></pre></div>
<p class="sub">Python</p>
<div class="codebox"><button class="ghost copy-code" type="button" data-target="code-wx-py">Copy</button><pre><code id="code-wx-py"></code></pre></div>
</div>
<div class="tabpane" role="tabpanel" id="pane-js" aria-labelledby="tab-js" hidden>
<p class="sub">The aligner this page runs (<a href="aligner.js" target="_blank" rel="noopener">aligner.js</a> +
<a href="deps.js" target="_blank" rel="noopener">deps.js</a>, transformers.js 4.3.2)</p>
<div class="codebox"><button class="ghost copy-code" type="button" data-target="code-js">Copy</button><pre><code id="code-js"></code></pre></div>
</div>
</section>
<details class="panel">
<summary>How it works, accuracy and limitations</summary>
<ol>
<li>Audio is decoded by your browser, resampled to 16 kHz mono and run through the CTC model in 30-second
windows with 2 seconds of context on each side, so long files use constant memory.</li>
<li>The transcript is lowercased, punctuation is set aside, and each character is looked up in the model's
10,288-character native-script vocabulary. Spaces become the word separator. Characters the model does not
know are skipped and listed with the results.</li>
<li>A Viterbi search finds the most likely path through the model's per-frame probabilities (20 ms frames),
with the same recursion as <code>torchaudio.functional.forced_align</code>. Untranscribed audio at the start
and end is absorbed, so leading silence or music does not shift the first word.</li>
<li>Each word's span extends into the silence around it up to the midpoint, as in ctc-forced-aligner, so
consecutive words share a boundary. The score is the average probability of the word's characters: words
that were not spoken as written score low.</li>
</ol>
<p>This is ctc-forced-aligner's native-script algorithm with its CLI defaults, running on ONNX Runtime Web with
int8 weights (about 370 MB, downloaded once and cached). On 32 test clips in seven languages, 98.3% of word
boundaries are identical to the full-precision PyTorch model and every one is within a single 20 ms frame. On
LibriSpeech dev-clean against Montreal Forced Aligner references, word starts and ends are within 37 ms of the
reference on average. See the <a class="model-href" href="https://huggingface.co/Cis-Labs/omniasr-ctc-300m-forced-aligner" target="_blank" rel="noopener">model card</a>
for the full evaluation.</p>
<p><strong>Limitations.</strong> Timing resolution is one 20 ms frame. The transcript must match the speech:
missing or extra words get squeezed into neighbouring gaps (look for low scores). Numbers written as digits
align less precisely than spelled-out numbers. Mandarin alignment is usable, but scores run lower because the
model often confuses homophones. Overlapping speakers, loud music and heavy noise degrade every aligner. The
page aligns up to 3 minutes per file; run the model locally for longer recordings.</p>
<p><strong>Credits.</strong> Model weights from Meta's <a href="https://github.com/facebookresearch/omnilingual-asr" target="_blank" rel="noopener">Omnilingual ASR</a>
(<code>omniASR_CTC_300M_v2</code>, Apache-2.0), converted to transformers by Cis Labs. Example audio:
LibriSpeech (CC BY 4.0) and FLEURS (CC BY 4.0); see the Space README for sources.</p>
</details>
<footer>
<a href="https://huggingface.co/Cis-Labs" target="_blank" rel="noopener"><b>Cis Labs</b></a> · Small, fast open
models that drop into the tools you already use.<br>
Running <code id="running">Cis-Labs/omniasr-ctc-300m-forced-aligner</code>
</footer>
</main>
</body>
</html>