UNPKG

@cloudraker/use-whisper

Version:

React Hook for OpenAI Whisper API with speech recorder and silence removal built-in.

50 lines (48 loc) 1.52 kB
type UseWhisperConfig = { apiKey?: string; autoStart?: boolean; autoTranscribe?: boolean; mode?: 'transcriptions' | 'translations'; nonStop?: boolean; removeSilence?: boolean; stopTimeout?: number; streaming?: boolean; timeSlice?: number; whisperConfig?: WhisperApiConfig; onDataAvailable?: (blob: Blob) => void; onTranscribe?: (blob: Blob) => Promise<UseWhisperTranscript>; whisperApiEndpoints?: WhisperAPIEndpointsConfig; }; type WhisperAPIEndpointsConfig = { transcriptions?: string; translations?: string; }; type UseWhisperTimeout = { stop?: NodeJS.Timeout; }; type UseWhisperTranscript = { blob?: Blob; text?: string; }; type UseWhisperReturn = { recording: boolean; speaking: boolean; transcribing: boolean; transcript: UseWhisperTranscript; pauseRecording: () => Promise<void>; startRecording: () => Promise<void>; stopRecording: () => Promise<void>; }; type UseWhisperHook = (config?: UseWhisperConfig) => UseWhisperReturn; type WhisperApiConfig = { model?: 'whisper-1' | string; prompt?: string; response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt'; temperature?: number; language?: string; }; declare const UNDEFINED_VOID_ONLY: unique symbol; type Destructor = () => void | { [UNDEFINED_VOID_ONLY]: never; }; export { Destructor, UseWhisperConfig, UseWhisperHook, UseWhisperReturn, UseWhisperTimeout, UseWhisperTranscript, WhisperAPIEndpointsConfig, WhisperApiConfig };