# Transcript Player

> A recording and its transcript together: the spoken line lights up, any line's time plays from there, search marks matches.

Page: https://uicontext.com/docs/components/transcript-player

Group: Chat.

## When to use

A recording and its transcript together: the spoken line lights up, any line's time plays from there, search marks matches. Use [Read Aloud](https://uicontext.com/docs/components/read-aloud.md) instead when there's no recording, only text to speak.

## Usage

```ts
import { TranscriptPlayer, type TranscriptSegment } from "./ui/uicontext/components/TranscriptPlayer.ts"

export const Recording = <M>(h: Html.H<M>, src: string, segments: ReadonlyArray<TranscriptSegment>) =>
	TranscriptPlayer(h, { props: { label: "Customer call", src, segments } })
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### A recorded standup

The example the page opens with: Transcript Player in “A recorded standup”.

```ts title="src/demo.ts" source="www/src/examples/transcript-player/demo.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { TranscriptPlayer } from "./ui/uicontext/components/TranscriptPlayer.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { standup, standupAudio } from "./standup.ts"

const styles = stylex.create({ wrap: { inlineSize: "min(100%, 44rem)" } })

// press Play, or a line's time to hear it; search for "export"
export const Standup = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.wrap)).children(
		TranscriptPlayer(h, { key: "standup", props: { label: "Standup, 4 March", src: standupAudio, segments: standup } }),
	)
```

### Beside the notes

In a narrow column the controls wrap and the lines keep their times.

```ts title="src/notes.ts" source="www/src/examples/transcript-player/notes.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { TranscriptPlayer } from "./ui/uicontext/components/TranscriptPlayer.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"
import { standup, standupAudio } from "./standup.ts"

const styles = stylex.create({
	page: {
		display: "grid",
		gridTemplateColumns: { default: "minmax(0, 1fr) minmax(0, 22rem)", "@media (max-width: 760px)": "minmax(0, 1fr)" },
		gap: space.xl,
		alignItems: "start",
		inlineSize: "100%",
	},
	notes: { display: "grid", gap: space.sm, fontSize: font.sm, color: color.fg },
	heading: { margin: 0, fontSize: font.lg, fontWeight: 600 },
	list: { margin: 0, paddingInlineStart: space.lg, display: "grid", gap: space.xs },
	meta: { margin: 0, color: color.muted },
})

// meeting notes with the recording beside them, so any point can be checked against what was said
export const MeetingNotes = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.page)).children(
		h.article.attrs(sx(styles.notes)).children(
			h.h2.attrs(sx(styles.heading)).children("Standup notes"),
			h.p.attrs(sx(styles.meta)).children("4 March · Ada, Wei, Priya"),
			h.ul.attrs(sx(styles.list)).children(
				h.li.children("Export timeout fixed: a missing index. Exports under 2 s."),
				h.li.children("Wei reruns three customers' jobs; Priya replies on their tickets."),
				h.li.children("Checkout redesign: review notes fixed, card marks tomorrow."),
				h.li.children("Ship checkout on Thursday."),
			),
		),
		TranscriptPlayer(h, { key: "notes", props: { id: "notes-recording", label: "Recording", src: standupAudio, segments: standup } }),
	)
```

### Sample data

The examples above import these files.

```ts title="src/standup.ts" source="www/src/examples/_shared/standup.ts"
import type { TranscriptSegment } from "./ui/uicontext/components/TranscriptPlayer.ts"

// a short standup and what was said in it, line by line
export const standupAudio = "/media/standup.mp3"

export const standup: ReadonlyArray<TranscriptSegment> = [
	{ start: 0.3, end: 4.04, speaker: "Ada Okafor", text: "Morning. Quick one today. Wei, how's the export fix?" },
	{ start: 4.44, end: 11.03, speaker: "Wei Chen", text: "It's merged. The timeout came from a missing index on export jobs. Exports now finish in under two seconds." },
	{ start: 11.43, end: 13.64, speaker: "Ada Okafor", text: "Great. Are any customers still waiting?" },
	{ start: 14.04, end: 17.69, speaker: "Wei Chen", text: "Three. I'll rerun their jobs this morning and reply on each ticket." },
	{ start: 18.09, end: 21.53, speaker: "Priya Raman", text: "I can take the replies, if you send me the ticket numbers." },
	{ start: 21.93, end: 25.13, speaker: "Ada Okafor", text: "Perfect. Priya, where are we on the checkout redesign?" },
	{ start: 25.53, end: 32, speaker: "Priya Raman", text: "The review notes are in. The pay button color and the contrast on the terms line are fixed. Card marks land tomorrow." },
	{ start: 32.4, end: 35.56, speaker: "Ada Okafor", text: "Then let's ship it on Thursday. Thanks, everyone." },
]
```

## API reference

**Props**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `string` | — | What the recording is: "Standup, 4 March". |
| `src` (required) | `string` | — | The audio, or a video played for its sound. |
| `segments` (required) | `TranscriptSegment[]` | — | — |
| `id` | `string` | `"transcript"` | Starts the ids inside it, unique on the page; "transcript" by default. |
| `locale` | `string` | — | For counts and shares; the browser's by default. |

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/transcript-player
```

With npm: `npx shadcn@latest add checkfu/uicontext/transcript-player`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/transcript-player`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/transcript-player`.

It writes these files:

- `src/ui/uicontext/components/FormControls.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/ShowText.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/TranscriptPlayer.ts`
- `src/ui/uicontext/components/domain/Format.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`
- `src/ui/uicontext/components/touch.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/TranscriptPlayer.ts](https://github.com/checkfu/uicontext/blob/main/src/TranscriptPlayer.ts)
- [src/touch.stylex.ts](https://github.com/checkfu/uicontext/blob/main/src/touch.stylex.ts)

## Used in

- [SaaS dashboard](https://uicontext.com/blocks/saas-dashboard.md)
- [Workflow builder](https://uicontext.com/blocks/automation-builder.md)
- [Team chat](https://uicontext.com/blocks/team-chat.md)
- [Whiteboard](https://uicontext.com/blocks/whiteboard.md)

## Related

- [Conversation](https://uicontext.com/docs/components/conversation.md) (`conversation`): What a person and an assistant say to each other, with actions, sources and tool calls on each message.
- [Composer](https://uicontext.com/docs/components/composer.md) (`composer`): Write and send a message, with attachments and modes.
- [Conversation Viewport](https://uicontext.com/docs/components/conversation-viewport.md) (`conversation-viewport`): Keeps the newest message in view, and lets you scroll back without losing your place.
- [Streaming Text](https://uicontext.com/docs/components/streaming-text.md) (`streaming-text`): A reply that appears as it's written, with a stop button.
- [Agent Plan](https://uicontext.com/docs/components/agent-plan.md) (`agent-plan`): What an agent did and plans to do, step by step, with each step's input and result.
- [Tool Call](https://uicontext.com/docs/components/tool-call.md) (`tool-call`): What an assistant's tools did, one past-tense row each, such as "Searched the web · 8 sources". Each opens to what it read.
