UNPKG

@minto-ai/microsoft-lat

Version:

微软LAT 语音转文本

43 lines (42 loc) 1.39 kB
import { DebounceConfig } from './utils/section-delay'; /** * 语音识别事件回调 * @typedef {object} EventCallbacks * @property {Function} [recognizing] - 识别中事件回调 * @property {Function} [recognized] - 识别完成事件回调 * @property {Function} [sessionStarted] - 会话开始事件回调 * @property {Function} [sessionStopped] - 会话结束事件回调 * @property {Function} [error] - 异常事件回调 */ interface EventCallbacks { recognizing?: (text: string) => void; recognized?: (text: string) => void; sessionStarted?: () => void; sessionStopped?: () => void; error?: (error: string) => void; } export default class MicrosoftLat { private speechConfig; private audioConfig; private recognizer; private results; private callbacks; private delayTimer; private autoControl; private sectionDelayParams; constructor({ key, region, language, autoControl, sectionDelayParams, }: { key: string; region: string; language?: string; autoControl?: boolean; sectionDelayParams?: DebounceConfig; }); private bindEvents; start(): void; stop(): void; destroy(): void; getResults(): string; on<T extends keyof EventCallbacks>(event: T, callback: EventCallbacks[T]): void; off<T extends keyof EventCallbacks>(event: T): void; } export {};