export type CobraWorkerRequestInit = { command : 'init' ; accessKey : string ; start ? : boolean ; } ; export type CobraWorkerRequestProcess = { command : 'process' ; inputFrame : Int16Array ; } ; export type CobraWorkerRequestVoid = { command : 'reset' | 'pause' | 'resume' | 'release' ; } ; export type CobraWorkerRequest = CobraWorkerRequestInit | CobraWorkerRequestProcess | CobraWorkerRequestVoid ; export type CobraWorkerResponseReady = { command : 'cobra-ready' ; } ; export type CobraWorkerResponseFailed = { command : 'cobra-failed' ; message : string ; } ; export type CobraWorkerResponseVoiceProbability = { command : 'cobra-detect' ; voiceProbability : number ; } ; export type CobraWorkerResponse = CobraWorkerResponseReady | CobraWorkerResponseFailed | CobraWorkerResponseVoiceProbability ; export interface CobraEngine { /** Release all resources acquired by Cobra */ release ( ) : Promise < void > ; /** Process a single frame of 16-bit 16kHz PCM audio */ process ( frame ) : Promise < number > ; /** The version of the Cobra engine */ readonly version : string ; /** The sampling rate of audio expected by the Cobra engine */ readonly sampleRate : number ; /** The frame length of audio expected by the Cobra engine */ readonly frameLength : number ; } export interface CobraWorker extends Omit < Worker , 'postMessage' > { postMessage ( command ) : void ; } export interface CobraWorkerFactory { create : ( accessKey : string , callback : ( voiceProbability : number ) => void , start ? : boolean ) => Promise < CobraWorker > ; }