Components
PreviousNext

Speech Input

A compound component for capturing and transcribing audio input using the Web Speech API with real-time visualization.

Speech Input is a compound component for capturing voice input with real-time transcription and animated audio visualization. Built on the Web Speech API with Radix design system principles.

Features

  • Real-time transcription with interim and final results
  • Animated equalizer showing audio activity
  • Flexible composition using Radix compound components
  • Browser support detection with graceful fallbacks
  • Language support with customizable locales
  • Callback hooks for lifecycle events
  • Keyboard editable input field
  • Cancellation support to discard transcriptions

Installation

Usage

Basic Setup

import { SpeechInput, SpeechInputTrigger, SpeechInputBase, SpeechInputCancel } from '@kit/ui/speech-input';
 
<SpeechInput
    lang="en-US"
    onSpeechStart={() => console.log('Started listening')}
    onSpeechChange={(text) => console.log('Final:', text)}
>
    <SpeechInputTrigger />
    <SpeechInputCancel />
    <SpeechInputBase asChild>
        <Input placeholder="Speak or type..." />
    </SpeechInputBase>
</SpeechInput>

With Custom Components

The asChild prop lets you compose with your own components:

<SpeechInputTrigger asChild>
    <Button>
        <SpeechInputEqualizer className="h-4 w-4" />
        Record
    </Button>
</SpeechInputTrigger>
 
<SpeechInputBase asChild>
    <CustomInput />
</SpeechInputBase>

Cancelling Input

The SpeechInputCancel button discards the transcription and prevents the onSpeechChange callback:

<SpeechInputCancel />  {/* Only enabled while listening */}

API Reference

SpeechInput

Root provider managing speech recognition state.

PropTypeDefault
children*
React.ReactNode
lang
string
onSpeechChange
function
onInterimSpeechChange
function
onSpeechStart
function

SpeechInputTrigger

Button to start/stop speech recognition. Supports asChild for composition.

SpeechInputCancel

Button to cancel recording and discard transcription. Disabled when not listening.

PropTypeDefault
hideWhenNotListening
boolean
false

SpeechInputEqualizer

Animated equalizer showing real-time audio activity.

PropTypeDefault
className
string

SpeechInputBase

Input field displaying transcribed text. Fully editable by keyboard.

PropTypeDefault
asChild
boolean
noInterim
boolean

Troubleshooting

IssueSolution
Microphone blockedCheck browser permissions and grant microphone access
No text appearingVerify microphone works and Web Speech API is supported
Language not recognizedUse valid language codes like en-US, fr-FR, de-DE
Input not editableUse asChild prop or ensure SpeechInputBase is properly composed

How is this guide?

Last updated on 11/2/2025