Transcript
FreeA 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.
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 demoMore 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.
<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.
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.
<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.
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 noid, so selection survives a reorder.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| segments | readonly SvTranscriptSegment[] | [] | The segments, in time order. Interim ones (`final: false`) are revised in place by the host. |
| speakers | readonly SvTranscriptSpeaker[] | [] | Who speaks — names and tones for the ids segments use. Unlisted ids show as themselves. |
| loading | boolean | false | True while the host is still fetching the transcript. |
| error | SvDataError | string | null | null | The transcript failed to load (a string or an `SvDataError`). |
| itemKey | SvItemKey<SvTranscriptSegment> | 'id' | Identity of a segment, a property name or a function. |
| filtered | boolean | false | The host has a filter or a server-side search applied, so an empty `segments` means "nothing matches" rather than "nothing transcribed". |
| currentTime | number | null | null | The player's position in seconds — the matching line is highlighted. Null highlights nothing. |
| player | SvTranscriptPlayer | null | null | A player to seek when a timestamp is pressed — `sv-media-player` fits, or anything with `seek(seconds)`. |
| playOnSeek | boolean | true | After seeking the linked player, also start it playing. |
| followPlayback | boolean | true | Scroll the line playing into view as playback moves. |
| live | boolean | false | Transcription 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. |
| showTimestamps | boolean | true | Show each segment's timestamp (a button that seeks). |
| showSpeakers | boolean | true | Show speaker names. |
| collapseSpeakers | boolean | true | Show a speaker's name only when the speaker changes. |
| maxHeight | string | '24rem' | Height cap of the scrolling list, as a CSS length (`24rem`, `60vh`, `none`). |
| searchable | boolean | true | Show the search box. |
| query | string (two-way) | '' | The search text (two-way). Matches are highlighted; it settles after `debounceMs`. |
| filterOnSearch | boolean | false | Only show segments that match the search, instead of highlighting them in place. |
| debounceMs | number | 250 | Milliseconds the search waits after the last keystroke before it settles (and `queryChange` fires). |
| copyable | boolean | true | Show the Copy button. |
| exportFormats | readonly SvTranscriptExportFormat[] | ['text', 'vtt'] | The download buttons to offer: plain `text` (`[1:04] Ana: …`) and `vtt` (WebVTT with voice spans). |
| exportFilename | string | 'transcript' | Download file name, without the extension. |
| ariaLabel | string | null | null | The transcript's accessible name. |
| locale | string | svLocale() | BCP-47 locale for the match count. |
| labels | Partial<SvTranscriptLabels> | {} | Per-instance text, merged over the registry's `display` labels. |
Outputs
| Event | Payload type | Description |
|---|---|---|
| seek | SvTranscriptSeekEvent | A timestamp was pressed. Emitted whether or not a `player` is linked. |
| copied | SvTranscriptExportEvent | The transcript was copied to the clipboard (only when the write succeeded). |
| exported | SvTranscriptExportEvent | A text or WebVTT file was downloaded. |
| retry | void | The host should re-run the failed transcript request (`error`). |
| clearFilters | void | "Clear filters" was pressed on a `filtered` empty result — the host should drop its filter. |
| queryChange | string | Emits 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.
<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.
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.