Transcript

Free

A speech transcript: speaker-labelled segments with timestamps, interim (still-changing) text drawn apart from final text, the line under the playhead highlighted, timestamps that seek a linked player, search with highlighted and counted matches, and copy / download as plain text or WebVTT. Live mode announces each new final line politely — never interim text — and follows the latest line until the reader scrolls up. Loading, error, empty and no-results states.

</>sv-transcript transcripttranscriptionspeechvoicecaptionswebvttcallrecordinglivespeaker

Complexity tier: Interactive The primitive bar, plus: its async states are declared — none is an answer — it has a keyboard model and restores focus, and any destructive action it offers can be undone.

import { SvTranscriptComponent } from '@styloviz/display/transcript';

Demo & usage

Basic usage

Usage example — open the gallery for the full interactive demo.

An interactive demo for this component lives in the gallery.

Open live demo

More examples

A call recording with a linked player

`player` takes anything with `seek(seconds)` — `sv-media-player` itself. A timestamp seeks it (and plays, unless `playOnSeek` is off) and emits `seek`; `currentTime` highlights the line playing and keeps it in view inside the list.

example.htmlAngular
<sv-transcript
  [segments]="segments"
  [speakers]="[{ id: 'agent', name: 'Maya' }, { id: 'caller', name: 'Jordan Lee', tone: 'accent' }]"
  [player]="player"
  [currentTime]="time()" />

Live transcription from a streaming service

Each result replaces the segment with the same id; `final: false` marks interim text. In `live` mode only a line's first final version is announced.

example.htmlAngular
onResult(r: SpeechResult) {
  const seg = { id: r.id, speaker: r.speaker, start: r.start, text: r.text, final: r.isFinal };
  this.segments.update((list) => upsertById(list, seg));
}

<sv-transcript [segments]="segments()" [live]="true" />

Search and export

`query` is two-way and settles after `debounceMs`; `filterOnSearch` hides lines that do not match. `exportFormats` picks the download buttons; `copied` / `exported` report exactly what was written.

example.htmlAngular
<sv-transcript [segments]="segments" [(query)]="query" [filterOnSearch]="true"
  [exportFormats]="['text', 'vtt']" exportFilename="call-1042" (exported)="audit($event)" />

Export without the component

The serialisers are plain functions — for a server job or a "send transcript" email.

example.htmlAngular
import { svTranscriptToText, svTranscriptToVtt } from '@styloviz/display';

const text = svTranscriptToText(segments, speakers); // [0:04] Jordan Lee: …
const vtt = svTranscriptToVtt(segments, speakers);   // WEBVTT … <v Jordan Lee>…

When to use

  • Call recordings in a helpdesk or CRM, meeting notes, interview and podcast transcripts, voicemail.
  • Live captions or dictation where interim results must be shown without being announced.
  • For a short voice turn with a mic button and level, use the Voice Assistant; for the recording itself, the Media Player.

Compare with

  • Media Player — Media Player plays a recording. Transcript shows its words — speakers, timestamps, interim and final text, search and export — and seeks the player when a timestamp is pressed.
  • Voice Assistant — Voice Assistant is a whole voice turn — mic button, level, barge-in — with a short transcript inside it. Transcript is the long-form record of a call or recording: searchable, exportable and linked to a player.

Async states

  • loading
  • error
  • retry

Item identity & owned state

Item key
itemKey — set this when your rows have no id, so selection survives a reorder.

Inputs

NameTypeDefaultDescription
segmentsreadonly SvTranscriptSegment[][]The segments, in time order. Interim ones (`final: false`) are revised in place by the host.
speakersreadonly SvTranscriptSpeaker[][]Who speaks — names and tones for the ids segments use. Unlisted ids show as themselves.
loadingbooleanfalseTrue while the host is still fetching the transcript.
errorSvDataError | string | nullnullThe transcript failed to load (a string or an `SvDataError`).
itemKeySvItemKey<SvTranscriptSegment>'id'Identity of a segment, a property name or a function.
filteredbooleanfalseThe host has a filter or a server-side search applied, so an empty `segments` means "nothing matches" rather than "nothing transcribed".
currentTimenumber | nullnullThe player's position in seconds — the matching line is highlighted. Null highlights nothing.
playerSvTranscriptPlayer | nullnullA player to seek when a timestamp is pressed — `sv-media-player` fits, or anything with `seek(seconds)`.
playOnSeekbooleantrueAfter seeking the linked player, also start it playing.
followPlaybackbooleantrueScroll the line playing into view as playback moves.
livebooleanfalseTranscription is happening now: new final lines are announced politely (interim text never is), a Live badge shows, and the view stays on the latest line until the reader scrolls up.
showTimestampsbooleantrueShow each segment's timestamp (a button that seeks).
showSpeakersbooleantrueShow speaker names.
collapseSpeakersbooleantrueShow a speaker's name only when the speaker changes.
maxHeightstring'24rem'Height cap of the scrolling list, as a CSS length (`24rem`, `60vh`, `none`).
searchablebooleantrueShow the search box.
querystring (two-way)''The search text (two-way). Matches are highlighted; it settles after `debounceMs`.
filterOnSearchbooleanfalseOnly show segments that match the search, instead of highlighting them in place.
debounceMsnumber250Milliseconds the search waits after the last keystroke before it settles (and `queryChange` fires).
copyablebooleantrueShow the Copy button.
exportFormatsreadonly SvTranscriptExportFormat[]['text', 'vtt']The download buttons to offer: plain `text` (`[1:04] Ana: …`) and `vtt` (WebVTT with voice spans).
exportFilenamestring'transcript'Download file name, without the extension.
ariaLabelstring | nullnullThe transcript's accessible name.
localestringsvLocale()BCP-47 locale for the match count.
labelsPartial<SvTranscriptLabels>{}Per-instance text, merged over the registry's `display` labels.

Outputs

EventPayload typeDescription
seekSvTranscriptSeekEventA timestamp was pressed. Emitted whether or not a `player` is linked.
copiedSvTranscriptExportEventThe transcript was copied to the clipboard (only when the write succeeded).
exportedSvTranscriptExportEventA text or WebVTT file was downloaded.
retryvoidThe host should re-run the failed transcript request (`error`).
clearFiltersvoid"Clear filters" was pressed on a `filtered` empty result — the host should drop its filter.
queryChangestringEmits the new `query` whenever it changes — the output half of `[(query)]`.

Wire it to your API

This component is headless about transport: it renders what you give it and reports what the user asks for. Nothing below requires @styloviz/data — drive it from whatever you already use.

Template

Bound to the names this component actually exposes.

usage.htmlAngular
<sv-transcript
  [segments]="segments()"
  [loading]="loading()"
  [error]="error()"
  [filtered]="filtered()"
  (queryChange)="onQueryChange($event)"
  (retry)="load()"
/>

Host class

Drive the three async inputs from your own fetch.

host.component.tsTypeScript
import { signal } from '@angular/core';
import { toSvDataError, type SvDataError } from '@styloviz/core';
import type { SvTranscriptSegment } from '@styloviz/display/transcript';

readonly segments = signal<SvTranscriptSegment[]>([]);
readonly loading = signal(false);
readonly error = signal<SvDataError | null>(null);
readonly filtered = signal<boolean>(false);
private query: string | null = null;

onQueryChange(query: string): void {
  this.query = query;
  void this.load();
}

async load(): Promise<void> {
  this.loading.set(true);
  this.error.set(null);
  try {
    const res = await fetch('/api/segments', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ query: this.query }) });
    if (!res.ok) throw res;
    this.segments.set(await res.json());
  } catch (e) {
    this.error.set(toSvDataError(e));
  } finally {
    this.loading.set(false);
  }
}
  • `queryChange` carries `string`, not an `SvDataQuery`, so `@styloviz/data`'s controller cannot take it as it is. The handler above keeps the latest one and fetches with it — map it to whatever your endpoint expects.
  • `debounceMs` (default 250) collapses a burst of typing into one request. Set it to 0 only when the query is driven by clicks.
  • Set `filtered` when a search or filter is active. It is the difference between "you have no orders" and "no orders match this filter" — telling a customer with 4,000 orders the first one reads as a bug.
  • Normalize failures with `toSvDataError()` from `@styloviz/core`. It derives `retryable` from the status, so a 404 does not get a "Try again" button that can only fail again.

Full walkthrough: Connecting to a backend.

Customization & theming

  • `showTimestamps`, `showSpeakers`, `collapseSpeakers` (name once per turn), `maxHeight` (a CSS length or `none`), `searchable`, `copyable`, `exportFormats` and `exportFilename`.
  • Speaker tones (`primary`, `accent`, `info`, `warning`, `danger`, `gray`) are theme tokens with `dark:` pairs; unset, speakers take them in turn.
  • `copy()`, `download(format)` and `jumpToLatest()` drive it from code; `svTranscriptToText`, `svTranscriptToVtt`, `svActiveSegmentIndex` and `svTranscriptParts` are exported.
  • Every string comes from the `display` labels (`transcript*` keys) in 12 language packs, or the per-instance `labels` input.
  • On paper the list prints in full (no scroll cap) and the toolbar is hidden.

Best practices

  • Do: Give segments a stable `id` — interim results are revised in place, and identity is what keeps the row (and its focus) when they are.
  • Do: Send `final: false` for interim results and replace them with the final version; only finals are announced, copied or exported.
  • Do: Bind `currentTime` from the player's `timeUpdate` with a short `timeUpdateInterval` (250 ms) and from `seekComplete`, so the highlight follows seeks too.
  • Don't: Don't put markup in `text` — it is rendered as text, and escaped in the WebVTT export.
  • Tip: Volume guide: every segment is a row, and the search scans them all. A one-hour call is ~800 segments, comfortable; for multi-hour archives, page by chapter or search server-side with `filtered`.

Accessibility

  • A labelled region with an ordered list of lines. Each timestamp is a button named "Play from 0:05, Jordan Lee" (or "Go to …" with no player); a line that continues a speaker's turn hides the name visually but still says it to a screen reader.
  • The line under the playhead has `aria-current="time"` and "now playing"; it is scrolled into view inside the list, never by scrolling the page.
  • In `live` mode a polite live region reads each new FINAL line once ("Jordan Lee: …"); interim text is marked "(still transcribing)" and never announced, because it changes several times a second. The list itself is not a live region.
  • Search is a `role="search"` box with a polite match count; Enter / Shift+Enter step matches and Escape clears. Matches are `<mark>`; the current one has a ring as well as a colour.
  • Copy reports its result in a status message and confirms only when the clipboard accepted the text.
  • The kit builds this without `@angular/aria`, which it does not depend on in 2.0.

Feedback on Transcript

Spotted a gap in this page, or something that didn't work as described? Comments are GitHub Discussions in the public styloviz/community repo, so posting needs a GitHub account.

Loads giscus.app and GitHub — nothing is fetched until you click.