/** * @file lib/Server * @description 服务端逻辑处理 * @author zhangyue49 */ import { type WebSocketClient } from '@bddh/starling-web-socket'; import { TtsType } from './interface'; interface DHServerInterface { action: string; requestId: string; body: { text: string; tts: TtsType; token: string; }; encodeType?: 'PCM' | 'OPUS'; } export interface DHErrServerInterface { action: string; requestId: string; code?: number; message?: string; error: Error; } type TextListener = (data: DHServerInterface | DHErrServerInterface, off?: () => void) => void; declare class Server { dhServerSocket: WebSocketClient | null; private tempPromise; private socketClosingPromise; private readonly url; private readonly renderMap; constructor(url: string); getSocket(token: string, listener: TextListener): Promise; createSocket(token: string, listener: TextListener): Promise; closeSocket(): Promise; textToAudio(message: DHServerInterface, listener: TextListener): Promise; private onRenderEventComplete; } export default Server;