Files
archived-orca/src/preload/api/speech-api.ts
T
Kelvin Amoaba 768df33d84 fix(dictation): handle cloud dictation's 10-minute cap, stalled uploads and bad API keys (#39114)
* fix(dictation): bound cloud uploads, stop at the 10-minute cap, check the OpenAI key on save

* refactor(dictation): share the OpenAI error reader
2026-11-07 00:22:24 +00:00

39 lines
1.6 KiB
TypeScript

import type { SecretAtRestProtection } from '../../shared/secret-at-rest-protection'
import type {
SpeechErrorEvent,
SpeechLifecycleEvent,
SpeechModelManifest,
SpeechModelState,
SpeechTranscriptEvent
} from '../../shared/speech-types'
export type SpeechApi = {
getCatalog: () => Promise<SpeechModelManifest[]>
getModelStates: () => Promise<SpeechModelState[]>
getOpenAiApiKeyStatus: () => Promise<{
configured: boolean
protection: SecretAtRestProtection | null
}>
saveOpenAiApiKey: (apiKey: string) => Promise<{ configured: boolean }>
clearOpenAiApiKey: () => Promise<{ configured: boolean }>
downloadModel: (modelId: string) => Promise<void>
cancelDownload: (modelId: string) => Promise<void>
deleteModel: (modelId: string) => Promise<void>
startDictation: (
modelId: string,
hotwords: string[] | undefined,
sessionId: string
) => Promise<void>
/** Resolves true when this chunk filled a cloud session's upload cap. */
feedAudio: (samples: Float32Array, sampleRate: number, sessionId?: string) => Promise<boolean>
stopDictation: (sessionId?: string) => Promise<void>
onPartialTranscript: (callback: (data: SpeechTranscriptEvent) => void) => () => void
onFinalTranscript: (callback: (data: SpeechTranscriptEvent) => void) => () => void
onDownloadProgress: (
callback: (data: { modelId: string; progress: number }) => void
) => () => void
onReady: (callback: (data: SpeechLifecycleEvent) => void) => () => void
onStopped: (callback: (data: SpeechLifecycleEvent) => void) => () => void
onError: (callback: (data: SpeechErrorEvent) => void) => () => void
}