@kitn.ai/ui
Version:
Framework-agnostic, Shadow-DOM web components for building AI chat interfaces — works in React, Vue, Angular, Svelte, or plain HTML. Authored in SolidJS.
27 lines (26 loc) • 1.22 kB
TypeScript
export interface UseSpeechRecognitionOptions {
/** Emit live, non-final partials via the `onInterim` callback passed to start(). */
interim?: boolean;
}
export interface SpeechRecognitionStartOptions {
/** BCP-47 language tag, e.g. `en-US`. */
lang?: string;
/** Called with each interim (non-final) transcript when `interim` is enabled. */
onInterim?: (text: string) => void;
}
/**
* Wrap the browser's Web Speech `SpeechRecognition` (Chrome/Safari; no Firefox).
* Mirrors `useVoiceRecorder`'s shape: an `isListening` signal, an `error` signal,
* and `start`/`stop` controls. `start()` resolves with the final transcript when
* recognition ends; `stop()` ends the in-progress session (resolving start()).
*
* Caveat (documented at the element): in Chrome this is cloud-based — audio is
* sent to Google — so it is "native to the browser," not on-device/private.
*/
export declare function useSpeechRecognition(options?: UseSpeechRecognitionOptions): {
isSupported: boolean;
isListening: import('solid-js').Accessor<boolean>;
error: import('solid-js').Accessor<string | null>;
start: (opts?: SpeechRecognitionStartOptions) => Promise<string>;
stop: () => void;
};