hydroxy

Transcript viewer

Timed speech segments that highlight the line being spoken, scroll to follow playback, seek on click and filter by search. Following pauses when the reader scrolls by hand and resumes on request.

0 s
12 segments

Usage

use hydroxy_leptos::transcript_viewer::{TranscriptSegment, TranscriptViewer};
use leptos::prelude::*;

fn segments() -> Vec<TranscriptSegment> {
    let lines = [
        ("Ana", "Welcome back to the show. Today we are talking about how teams ship audio features."),
        ("Ben", "Thanks for having me. I have been building voice tools for about six years now."),
        ("Ana", "Let's start with the basics. What does a transcript give a listener?"),
        ("Ben", "A way in. You can scan it, search it, and jump to the part you care about."),
        ("Ana", "And the highlighted line follows along as the audio plays."),
        ("Ben", "Right, until you scroll away. Then it should leave you alone."),
        ("Ana", "That is the part people get wrong. The view fights the reader."),
        ("Ben", "So we pause following, and offer a button to catch up again."),
        ("Ana", "Which brings us to search. Do you filter the list or highlight matches?"),
        ("Ben", "Filtering keeps the page short. You still click a line to seek to it."),
        ("Ana", "Last question: what would you change about your first version?"),
        ("Ben", "I would write the timing checks earlier. Overlapping segments caused most of our bugs."),
    ];
    lines
        .iter()
        .enumerate()
        .map(|(i, (who, text))| {
            let start = f64::from(u8::try_from(i).unwrap_or(0)) * 6.0;
            TranscriptSegment::new(format!("s{i}"), *who, start, start + 6.0, *text)
        })
        .collect()
}

#[component]
pub fn Demo() -> impl IntoView {
    let (time, set_time) = signal(0.0_f64);
    let (playing, set_playing) = signal(false);
    // A stand-in for a real player's clock: 4 ticks a second while "playing".
    Effect::new(move |_| {
        let handle = set_interval_with_handle(
            move || {
                if playing.get_untracked() {
                    set_time.update(|t| *t = (*t + 0.25) % 72.0);
                }
            },
            std::time::Duration::from_millis(250),
        );
        on_cleanup(move || {
            if let Ok(h) = handle {
                h.clear();
            }
        });
    });

    view! {
        <div style="display: grid; gap: var(--space-4); max-width: 640px;">
            <div style="display: flex; align-items: center; gap: var(--space-4); font: var(--text-sm);">
                <button type="button" on:click=move |_| set_playing.update(|p| *p = !*p)>
                    {move || if playing.get() { "Pause" } else { "Play" }}
                </button>
                <span>{move || format!("{:.0} s", time.get())}</span>
            </div>
            // Scroll the list by hand and following stops. Click a line to jump to it.
            <TranscriptViewer
                segments=segments()
                current_time=time
                searchable=true
                max_height=260
                on_seek=move |t| set_time.set(t)
            />
        </div>
    }
}

Anatomy

Componentdata-partRenders
TranscriptViewerrootdata-follow is following or suspended
(inside)toolbarHolds the search field, the segment count and the follow button
(inside)searchFilters by speaker or text, ignoring case
(inside)countrole=status: 3 of 12 segments
(inside)resume-followDisabled while following
(inside)viewportScrolling region, focusable. Wheel, touch, scroll keys and scrollbar drags suspend following
(inside)segmentA button per segment. data-active marks the one being spoken; aria-current too
(inside)speaker / time / textThe pieces of one segment

Keyboard

KeyDoes
Enter / SpaceOn a segment: seek to its start
↑ ↓ PgUp PgDn Home EndOn the viewport: scroll, and stop following

Props

PropTypeNotes
segmentsVec<Segment>id, speaker, start, end and text, in time order
current_timef64Playback position in seconds
on_seekCallback<f64>A segment was chosen: seek to this start time
searchableboolShow the search field
labelOption<String>Accessible name of the scrolling region
max_heightu32Height of the region in pixels. Default 320
start_suspendedboolStart with following off
on_follow_changeCallback<bool>Following turned on or off
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts