Calm motion: animations on this site only fade, with no movement
Voice input
A microphone button that turns speech into text
Lets a person speak instead of type, for example into the prompt input or a field for notes. It uses the Web Speech API of the browser, so it adds no library. To record sound as a file, use the audio recorder.
Basic
v-modelis the text. Each finished phrase is added at the end, and each one also emitsresult. Put the samev-modelon a field to type and speak into the same text.- A click starts the dictation, and a second click stops it. While the browser listens, the button is filled and a ring grows with the loudness of the voice. The words that are not final yet show in gray next to the button.
langsets the language of the speech, such asid-ID. The default is the language of the page. Withcontinuous(on by default), the dictation goes on after a pause.- Chrome, Edge, and Safari have the Web Speech API. In other browsers, the button is disabled, and a note says that speech to text is not available. Chrome sends the sound to a server to read it.
- If the person does not allow the microphone, a note says so and the component emits
error. - The button is a toggle with
aria-pressed. A hidden status line says "Listening…" and "Dictation stopped". Change the words withlabelsor a label pack:start,stop,listening,stopped,unsupported, anddenied.
Usage
ts
import { BlessVoiceInput } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
lang | string | — | the language of the speech, for example `id-ID`; default: the language of the page |
continuous | boolean | true | keep listening after a pause, until the reader stops it |
disabled | boolean | — | |
labels | Partial<{ start: string; stop: string; listening: string; stopped: string; unsupported: string; denied: string; }> | — | |
modelValue | string | "" | the text: each finished phrase is added at the end |
Events
| Name | Payload | Description |
|---|---|---|
update:modelValue | [value: string] | |
error | [error: string] | |
result | [text: string] |