hydroxy

Voice session

The screen for a live voice conversation: a status orb, mute and end controls and a transcript. The audio transport is yours; the component takes the phase and reports what the user asked for.

Ready to talk

Transport events:

Usage

use hydroxy_leptos::voice_session::{Phase, Speaker, TranscriptTurn, VoiceSession};
use leptos::prelude::*;

pub fn demo() -> AnyView {
    // The owner holds the phase and reports what the transport is doing.
    let (phase, set_phase) = signal(Phase::Idle);
    let (turns, set_turns) = signal(Vec::<TranscriptTurn>::new());

    let say = move |speaker, text: &str| set_turns.update(|t| t.push(TranscriptTurn::new(speaker, text)));

    view! {
        <div style="display: grid; gap: var(--space-6); max-width: 480px;">
            <VoiceSession
                phase=phase
                transcript=turns
                error_message="The connection dropped. Check your network and try again."
                on_start=move |()| set_turns.set(Vec::new())
                on_phase_change=move |p| set_phase.set(p)
            />

            // Stand-ins for the audio transport, which is the owner's job.
            <div style="display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center;">
                <span style="font: var(--text-sm); color: var(--text-2);">"Transport events:"</span>
                <hydroxy_leptos::button::Button
                    variant=hydroxy_leptos::button::ButtonVariant::Secondary
                    size=hydroxy_leptos::button::ButtonSize::Sm
                    on_click=move |_| set_phase.set(Phase::Listening)
                >
                    "Connected"
                </hydroxy_leptos::button::Button>
                <hydroxy_leptos::button::Button
                    variant=hydroxy_leptos::button::ButtonVariant::Secondary
                    size=hydroxy_leptos::button::ButtonSize::Sm
                    on_click=move |_| {
                        say(Speaker::User, "What is on my calendar tomorrow?");
                        set_phase.set(Phase::Speaking);
                    }
                >
                    "Assistant speaks"
                </hydroxy_leptos::button::Button>
                <hydroxy_leptos::button::Button
                    variant=hydroxy_leptos::button::ButtonVariant::Secondary
                    size=hydroxy_leptos::button::ButtonSize::Sm
                    on_click=move |_| {
                        say(Speaker::Assistant, "You have a design review at ten and lunch with Ana at one.");
                        set_phase.set(Phase::Listening);
                    }
                >
                    "Assistant stops"
                </hydroxy_leptos::button::Button>
                <hydroxy_leptos::button::Button
                    variant=hydroxy_leptos::button::ButtonVariant::Secondary
                    size=hydroxy_leptos::button::ButtonSize::Sm
                    on_click=move |_| set_phase.set(Phase::Error)
                >
                    "Drop the connection"
                </hydroxy_leptos::button::Button>
            </div>
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
VoiceSessionrootA labelled section. data-state is idle, connecting, listening, speaking or error
(inside)orbDecorative. Rings and pulses change with the phase; data-muted while muted
(inside)statusrole=status text for the phase, or the error message
(inside)controlsStart button, or mute and end buttons while a call is up
(inside)muteToggle button with aria-pressed, enabled while listening or speaking
(inside)transcriptrole=log list that announces new lines politely
(inside)turnOne line. data-speaker is user or assistant; data-partial while it is still arriving

Keyboard

KeyDoes
TabMove between the mute, end and start buttons
Enter / SpacePress the focused button

Props

PropTypeNotes
phaseOption<Phase>Controlled phase: Idle, Connecting, Listening, Speaking or Error. Drive it from the transport
default_phasePhaseInitial phase when uncontrolled
mutedOption<bool>Controlled mute. Pair with on_mute_change
default_mutedboolInitial mute when uncontrolled
transcriptVec<TranscriptTurn>Oldest first. A partial turn shows an ellipsis
error_messageStringShown instead of the status while the phase is Error
on_startCallback<()>The user asked to start or retry. Open the transport
on_endCallback<()>The user ended or cancelled. Close the transport
on_mute_changeCallback<bool>Apply the new flag to the microphone track
on_phase_changeCallback<Phase>The phase the user's action asks for. Set it on your signal
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