Every extension
dictation
Speak, and the words arrive at the caret.
Built on the browser's own speech recognition, so nothing is sent anywhere the browser does not already send it and nothing is downloaded. Words the recogniser is still deciding on are drawn after the caret as a decoration, and become document text only once it settles — so a half-heard phrase is never in the undo history.
`startDictation` needs a mounted editor and a browser that can listen; `editor.can.startDictation()` says whether both are true without turning the microphone on. Where the API is missing, every command returns false.
Adding it
import { createEditor, document, paragraph, text, dictation } from '@matrajs/core'
const editor = createEditor({
extensions: [document, paragraph, text, dictation({ … })],
element: document.querySelector('#editor'),
})
There is no separate package · dictation is already in @matrajs/core, and an extension you do not import is not in your bundle. document, paragraph and text are the floor every document needs.
Options
| Field | Type | |
|---|---|---|
lang | string | BCP 47 tag. Defaults to the browser's language. |
continuous | boolean | Keep listening after a pause. Default true. |
interim | boolean | Show what is being said before it is final. Default true. |
className | string | Class on the provisional text. Default `matra-dictation-interim`. |
Commands
-
editor.commands.startDictation() -
editor.commands.stopDictation() -
editor.commands.toggleDictation() -
editor.commands.setDictation()
Styles
This one needs a stylesheet to look right, and ships the minimum as a string rather than a file · nothing is loaded unless you load it.
import { dictationCSS } from '@matrajs/core'
const style = document.createElement('style')
style.textContent = dictationCSS
document.head.append(style)