Installation
Usage
"use client"
import * as React from "react"
import { VoiceAgent, type VoiceState } from "@/components/voice-agent"
export function ReservationCall() {
const [state, setState] = React.useState<VoiceState>("idle")
const [startedAt, setStartedAt] = React.useState<number>()
const [muted, setMuted] = React.useState(false)
// Wire this to your voice SDK: pass its audio element and microphone stream
// as agentAudio and userAudio, and set the state from its events.
return (
<VoiceAgent
agent={{ name: "Nova", role: "Reservations" }}
state={state}
active={startedAt !== undefined}
startedAt={startedAt}
muted={muted}
onMutedChange={setMuted}
onStart={() => {
setStartedAt(Date.now())
setState("listening")
}}
onEnd={() => {
setStartedAt(undefined)
setState("idle")
}}
/>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| agent | { name, role?, colors? } | — | Who is talking. Changing agents blends the orb's two colours into the next pair. |
| state | VoiceState | — | idle, connecting, listening, thinking, speaking, interrupted, reconnecting or handoff. You run the call; it draws each one. |
| layout | "call" | "widget" | "aura" | "call" | A call screen, a pill for the corner of a page that opens into a panel, or a glow along the bottom of what it fills. |
| agentAudio / userAudio | MediaStream | HTMLMediaElement | — | The agent's voice (the orb follows it) and your microphone (the waveform follows it). |
| levels / userLevel | () => [low, mid, high] / () => number | — | Read levels yourself instead, from any SDK; called every frame. |
| caption | { who, text, spoken?, interrupted? } | — | What is being said now: spoken words light up, the rest wait faded, or are struck through when cut off. |
| transcript / showTranscript | VoiceMessage[] / boolean | — / false | The conversation so far, with quiet notes for transfers and dropped lines. |
| active / startedAt | boolean / number | false / — | A call is in progress, and when it started, for the timer. |
| muted / onMutedChange | boolean / (muted) => void | false | The mute button, also on Space while focus is inside. |
| pushToTalk / onTalkStart / onTalkEnd | boolean / () => void | false | Talk only while holding the button or Space. |
| connection / noisy | { quality, latency? } / boolean | — | Shows the line's quality and delay, and warns about a noisy room. |
| activity | ReactNode | — | What the agent is doing, like a tool call. |
| onStart / onEnd / onSend | () => void / (text) => void | — | Start and end the call (Escape ends it), and typing instead of talking. |
| open / defaultOpen / onOpenChange | boolean | false | The widget's panel. |
Accessibility
- A labelled region; screen readers hear the state and each finished line, not every word.
- Mute and push to talk are real buttons with aria-pressed; Space mutes or talks and Escape ends the call while focus is inside.
- People can type instead of talking.
- The widget's orb is a button with aria-expanded.
- Under prefers-reduced-motion the orb holds its shape and only glows with the voice.
Changelog
- v1.0.1Latest
Words still to be spoken are muted instead of faded, so the caption keeps full text contrast at every moment of a line.
- v1.0.0
First release.