@corti/dictation-web package provides a set of custom elements that handle microphone management, audio streaming, transcript display, and voice commands on top of the Corti API. It works with any frontend framework or plain HTML.
Package: @corti/dictation-web on npm | Examples: corti-examples/dictation | Live demo: CodePen
<corti-dictation>— opinionated, all-in-one component with built-in UI (recommended for most use cases)- Modular components — individual building blocks (
<dictation-root>,<dictation-recording-button>, etc.) for fully custom layouts
Installation
Module import
Quick start
Configuration
SetdictationConfig as a JavaScript property to configure the transcription engine. The type matches the config message from the Transcribe WebSocket API.
Modular components
For custom UI layouts, use individual components inside a<dictation-root> parent:
| Component | Description |
|---|---|
<dictation-root> | Context provider. Same properties as <corti-dictation> (auth, config, devices, keybindings). Add noWrapper attribute to remove default styling. |
<dictation-recording-button> | Start/stop button with audio visualization. Supports allowButtonFocus. Has startRecording(), stopRecording(), toggleRecording(), openConnection(), closeConnection() methods. |
<dictation-settings-menu> | Settings panel with device and language selectors. Supports settingsEnabled. |
<dictation-device-selector> | Standalone device dropdown. Supports disabled. |
<dictation-language-selector> | Standalone language dropdown. Supports disabled. |
<dictation-keybinding-selector> | Keybinding configuration. Supports keybindingType ("push-to-talk" or "toggle-to-talk") and disabled. |
Keyboard shortcuts
The component supports two keybinding modes:| Mode | Behavior | Default key |
|---|---|---|
| Push-to-talk | Hold key to record, release to stop | Space |
| Toggle-to-talk | Press to start, press again to stop | Enter |
event.key names (e.g. "Space", "k", "Meta") or event.code values (e.g. "KeyK", "Backquote"). Modifier combinations are not supported.
When both keybindings are set to the same key, toggle-to-talk takes priority.
Preventing keybinding activation
Use thekeybinding-activated event to conditionally block keybindings:
Voice commands
Voice commands let users control your application by speaking phrases. Configure commands viadictationConfig.commands — each command has a phrases pattern and optional variables. The component emits a command event when a phrase is matched. See the Transcribe API reference for the full command schema.
Attribute formatting
| Type | Format | Example |
|---|---|---|
| Boolean | Presence = true, absence = false | <corti-dictation debug-display-audio> |
| String | Attribute value | accessToken="token" |
| Array | Comma-separated | settingsEnabled="device,language" |
| Object | JavaScript property only | dictation.authConfig = { ... } |
Resources
- npm package — latest version and install info
- Examples — basic, custom UI, styling, and token refresh examples
- CodePen demo — interactive live demo
- API Reference — properties, methods, and events for every component
- Authentication Guide — access tokens and automatic refresh
- Proxy Guide — route WebSocket traffic through your own server
- Styling Guide — CSS custom properties and theming
- Transcribe API Reference — underlying WebSocket API specification
For support or questions, reach out through help.corti.app