Voice Input

A mic button that morphs into a recording pill with a live Web Audio waveform, elapsed timer, cancel and confirm actions, a shimmering transcription state, and graceful permission-denied fallback.

Preview

Voice Input preview width

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @karaui/voice-input
@karaui not found? Add it to components.json
{
  "registries": {
    "@karaui": "https://karaui.kamisama-v0.my.id/r/{name}.json"
  }
}

@karaui is in shadcn's public registry directory, so the latest CLI needs no setup. On an older CLI, merge this into the existing file once and every @karaui/… install resolves.

API Reference

onTranscribe?
((audio: Blob) => Promise<string>)

Turns the recorded audio into text. Receives the MediaRecorder blob (an empty blob when `simulate` is on). Not called when `mode="speech"` and the browser's SpeechRecognition API handled the transcript.

—
onTranscript?
((text: string) => void)

Called with the final transcript when the done state is reached.

—
onCancel?
(() => void)

Called when recording or transcription is cancelled.

—
onStateChange?
((state: VoiceInputState) => void)
—
onError?
((error: unknown) => void)
—
mode?
"recorder" | "speech"

`recorder` captures audio and delegates to `onTranscribe`. `speech` uses the browser SpeechRecognition API when available, falling back to `recorder` otherwise.

recorder
lang?
string

BCP-47 language for `mode="speech"`. Defaults to the browser language.

—
simulate?
boolean

Fake an animated waveform without touching the microphone.

false
bars?
number

Number of waveform bars.

24
maxDuration?
number

Auto-confirm after this many seconds of recording.

—
doneDuration?
number

How long the done state shows the transcript before returning to idle (ms).

2400
disabled?
boolean
false
className?
string
—

Composition

Place the voice control beside or inside the composer so a finished transcript lands in the same draft the person would otherwise type.

Chat
├── MessageScroller
└── PromptInput
    └── VoiceInput

Note: Prompt Input receives the transcript as an editable draft. Loading States matches the shimmer used while transcription runs. Message displays the spoken prompt once it is sent.

How it works

Voice input lets a person speak an instruction instead of typing it. It owns microphone access, recording feedback, and the handoff to transcription, while the application decides which speech-to-text service turns audio into the prompt.

Updated