# VoiceControl

Pick a microphone, record, watch the input level and follow the transcription.

- **Use it for**: Microphone choice, capture controls and levels.
- **Not for**: Playback. Try [AudioPlayer](https://unseenui.com/components/audio-player/).

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { VoiceControl } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<VoiceControl variant="panel" capture={capture} transcription={transcription} status={status} onRequestStart={startVoice} onRequestStop={stopVoice} onRequestCancel={cancelVoice} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `capture` | `VoiceCaptureSnapshot` |  |
| `className` | `string` | Added to the root element, after the component's own classes. |
| `connection` | `"unknown" \| ConnectionState` |  |
| `deviceId` | `string` |  |
| `devices` | `readonly VoiceDevice[]` |  |
| `error` | `string` |  |
| `inputLevel` | `number` |  |
| `label` | `string` | Distinguishes multiple voice controls and their disclosure landmarks. |
| `onCancel` | `(() => void)` |  |
| `onDeviceChange` | `((id: string) => void)` |  |
| `onRequestCancel` | `((context: VoiceContext) => void)` |  |
| `onRequestDeviceChange` | `((request: VoiceDeviceRequest) => void)` |  |
| `onRequestStart` | `((context: VoiceContext) => void)` |  |
| `onRequestStop` | `((context: VoiceContext) => void)` |  |
| `onStart` | `(() => void)` |  |
| `onStop` | `(() => void)` |  |
| `state` | `VoiceState` | Legacy aggregate state. |
| `status` | `VoiceAvailability` |  |
| `submission` | `SubmissionState` |  |
| `transcript` | `{ text: string; final: boolean; }` |  |
| `transcription` | `VoiceTranscription` |  |
| `variant` | `"compact" \| "bar" \| "panel"` |  |

## Keyboard

Tab reaches controls; Enter or Space activates buttons. Accordions use arrow keys, Home and End. Select menus support arrows and typeahead; Escape closes menus and dialogs and restores focus.

## Works with

[AudioPlayer](https://unseenui.com/components/audio-player/), [Transcription](https://unseenui.com/components/transcription/), [VoiceSelector](https://unseenui.com/components/voice-selector/), [Persona](https://unseenui.com/components/persona/)

Page: https://unseenui.com/components/voice-control/
