View as Markdown

API reference: @salmonui/inputs/speech-to-text

SpeechRecognizerinterface

import type { SpeechRecognizer } from '@salmonui/inputs/speech-to-text';
interface SpeechRecognizer {
    lang: string;
    continuous: boolean;
    interimResults: boolean;
    start(): void;
    stop(): void;
    abort(): void;
    onstart: ((event: unknown) => void) | null;
    onresult: ((event: SpeechRecognizerResultEvent) => void) | null;
    onerror: ((event: {
        readonly error: string;
        readonly message?: string;
    }) => void) | null;
    onend: ((event: unknown) => void) | null;
}

The subset of the Web Speech SpeechRecognition interface the hook uses. A cloud recognizer implements it; one instance per session.

SpeechRecognizer members (10)
NameSignatureDescription
langlang: string;
continuouscontinuous: boolean;
interimResultsinterimResults: boolean;
startstart(): void;
stopstop(): void;
abortabort(): void;
onstartonstart: ((event: unknown) => void) | null;
onresultonresult: ((event: SpeechRecognizerResultEvent) => void) | null;
onerroronerror: ((event: { readonly error: string; readonly message?: string; }) => void) | null;
onendonend: ((event: unknown) => void) | null;