UNPKG

@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.

35 lines (34 loc) 1.85 kB
/** Imperative handle exposed via `controllerRef` — surfaces the recorder's latent * start/stop so the `<kai-voice-input>` facade can forward them as instance * methods (push-to-talk). Both run the SAME getUserMedia → blob → transcription * path as clicking the mic, so manual + programmatic emit identically. */ export interface VoiceInputController { /** Begin recording programmatically (same path as clicking the mic). */ start(): void; /** Stop the in-progress recording (produces the blob → onTranscribe). */ stop(): void; } export interface VoiceInputProps { onTranscribe: (audio: Blob) => Promise<string>; onTranscription: (text: string) => void; disabled?: boolean; class?: string; /** Host supplied a `transcribe` callback. When true the MediaRecorder → * onTranscribe path runs. When false the component prefers native * SpeechRecognition (capable browsers), falling back to record-only. */ hasTranscribe?: boolean; /** BCP-47 language tag for native recognition (e.g. `en-US`). */ lang?: string; /** Emit live partial transcripts via `onInterim` (native path only). */ interim?: boolean; /** Live partial transcript from native recognition (when `interim`). */ onInterim?: (text: string) => void; /** Fires whenever recording starts or stops. Guarded against the spurious * initial `false` — only true transitions emit (the facade maps this to * kai-recording-change). */ onRecordingChange?: (recording: boolean) => void; /** Receive the imperative controller once mounted. The `<kai-voice-input>` * facade forwards these as element methods (start/stop). */ controllerRef?: (controller: VoiceInputController) => void; } export declare function VoiceInput(props: VoiceInputProps): import("solid-js").JSX.Element;