@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
77 lines (76 loc) • 2.1 kB
TypeScript
import type { string_language } from './string_token';
/**
* Stable speech-recognition error codes consumed by UI and telemetry.
*/
export type SpeechRecognitionErrorCode = 'permission-denied' | 'audio-capture' | 'network' | 'no-speech' | 'aborted' | 'unsupported-browser' | 'unknown';
/**
* Interface for speech-to-text recognition
*
* @🚉 fully serializable as JSON
*/
export type SpeechRecognition = {
/**
* Start the speech recognition
*/
$start(options: SpeechRecognitionStartOptions): void;
/**
* Stop the speech recognition
*/
$stop(): void;
/**
* Current state of the speech recognition
*/
readonly state: SpeechRecognitionState;
/**
* Subscribe to speech recognition events
*/
subscribe(callback: (event: SpeechRecognitionEvent) => void): () => void;
};
/**
* Options for starting speech recognition
*/
export type SpeechRecognitionStartOptions = {
/**
* Language for speech recognition
* @default 'en-US'
*/
readonly language?: string_language;
/**
* Whether to return interim results
* @default true
*/
readonly interimResults?: boolean;
/**
* Enables a more sensitive profile for quiet speech.
*/
readonly whisperMode?: boolean;
/**
* Optional text prompt used to preserve continuity across multiple transcription chunks.
*/
readonly transcriptionPrompt?: string;
};
/**
* Current state of the speech recognition
*/
export type SpeechRecognitionState = 'IDLE' | 'STARTING' | 'RECORDING' | 'TRANSCRIBING' | 'ERROR';
/**
* Event emitted by speech recognition
*/
export type SpeechRecognitionEvent = {
readonly type: 'START';
} | {
readonly type: 'TRANSCRIBING';
} | {
readonly type: 'RESULT';
readonly text: string;
readonly isFinal: boolean;
} | {
readonly type: 'ERROR';
readonly message: string;
readonly code?: SpeechRecognitionErrorCode;
readonly providerId?: string;
readonly canRetry?: boolean;
readonly canOpenBrowserSettings?: boolean;
} | {
readonly type: 'STOP';
};