Prodular UI

Voice input

AIPro

Dictation for AI features: a mic button with a listening state, live level bars, a timer, a stop button and a transcript preview with interim words.

npx prodular-ui add voice-input

Part of Prodular UI Pro. Preview and read the docs freely, install with a license. See pricing

Dictate visit notes

Press the mic, watch the levels and the transcript fill in, then stop to transcribe. Levels are simulated in this demo; use useAudioLevels with a real microphone stream.

Visit notes

WO-3318 · Harbor Point, unit 4

Press the mic and describe the visit.

States

Idle, listening and processing.

Idle
Listening
0:14
Processing
0:21

Anatomy

<VoiceInput status={status}>  <VoiceInputButton onClick={start} />  <VoiceLevels levels={levels} />  <VoiceInputTimer seconds={seconds} />  <VoiceInputStop onClick={stop} /></VoiceInput><VoiceTranscript interim={interim}>{finalText}</VoiceTranscript>

Guidance

Use it when

  • Use it where people describe something faster than they type it: visit notes, ticket replies, prompts on mobile.
  • Show interim words muted and settled words in full color so people see the recognizer working.
  • Let people edit the transcript before it is sent or saved.

Avoid

  • Starting to listen without a press. The microphone only opens on an explicit action.
  • Sending the transcript automatically when listening stops.
  • Hiding the timer. People need to know the mic is still on.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Only request microphone access with getUserMedia inside the click handler of VoiceInputButton, and stop every track of the stream when the person presses stop or leaves the view.
  • Pass status on every render: listening while the mic is open, processing while the final transcript is computed, idle otherwise.
  • Drive VoiceLevels from useAudioLevels(stream) with a real stream. Do not show fake levels in production.
  • Always render VoiceInputStop and VoiceInputTimer while listening. Pass interim to VoiceTranscript for words the recognizer may still change.
  • Put the transcript in an editable field after processing. Never submit it without the person confirming.

API

VoiceInput

PropTypeDefaultDescription
status"idle" | "listening" | "processing""idle"Exposed as data-status. Shapes the container and the parts.

VoiceInputButton

PropTypeDefaultDescription
Button propsComponentProps<typeof Button>Starts listening. Pressed and pulsing while listening.

VoiceLevels

PropTypeDefaultDescription
levelsnumber[]One value from 0 to 1 per bar, newest last.

VoiceInputTimer

PropTypeDefaultDescription
secondsnumberElapsed listening time.

VoiceInputStop

PropTypeDefaultDescription
Button propsComponentProps<typeof Button>Stops and transcribes. Shows a spinner while processing.

VoiceTranscript

PropTypeDefaultDescription
interimstringWords that may still change, shown muted after children.

useAudioLevels

PropTypeDefaultDescription
(stream, bars)(MediaStream | null, number) => number[]Live levels from a microphone stream.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add voice-input# or, with the registry in components.jsonnpx shadcn@latest add @prodular/voice-input