import TypedEmitter from "typed-emitter"; export type WillowClientEvents = { /** Emitted whenever the client wants to log something. This is verbose. */ onLog: (msg: string) => void; /** Emitted whenever the client encounters an error. */ onError: (msg: string) => void; /** Emitted whenever the client receives a data channel message from the server */ onMessage: (msg: DataChannelMessage) => void; /** Emitted whenever the client receives a speech to text inference result from the server */ onInfer: (results: { text: string; time: number; }) => void; /** Emitted when the WebRTC connection is closed for any reason. */ onClose: () => void; /** Emitted when the WebRTC connection is first opened. */ onOpen: () => void; }; /** Config class for willow client. */ export interface WillowClientConfig { /** See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia */ constraints?: MediaStreamConstraints; /** See https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/RTCPeerConnection */ rtcConfig?: RTCConfiguration; /** The host to connect to for infrance. This should include path. */ host?: string; } /** Type of any data channel message returned by the server. */ export interface DataChannelMessage { type: string; message?: string; obj?: T; } declare const WillowClient_base: new () => TypedEmitter; /** * The main class for interacting with library. An event emitter that establishes and maintains connection. */ export declare class WillowClient extends WillowClient_base { config: WillowClientConfig; pc: RTCPeerConnection; dc: RTCDataChannel; stream: MediaStream | undefined; private lastStop; recording: boolean; constructor(config: WillowClientConfig); get track(): MediaStreamTrack | undefined; get sender(): RTCRtpSender | undefined; /** Indicates if the client is currently connected. */ get connected(): boolean; /** Mutes the current client. Generally you want to call `stop()` instead. */ mute(mute: boolean): Promise; /** Starts sending recorded voice to the server. Call `stop()` to trigger inference. */ start(): Promise; /** Used internally. Can also be called if you want to send custom message to server on data channel. */ sendMessage(message: DataChannelMessage): Promise; /** Stops recording and triggers inference which will be emmited via "onInfer" event. */ stop(): Promise; /** Forces the WebRTC connection closed */ disconnect(): Promise; /** After the client is constructed call this to initalize and connect to ASR server.*/ init(): Promise; private negotiate; } export {};