UNPKG

@voice-ping/cognitive-services-speech

Version:

VoicePing Cognitive Services Speech SDK for JavaScript forked from Microsoft

76 lines (75 loc) 4.63 kB
import { ConnectionEvent, EventSource, IAudioSource, IAudioStreamNode, IConnection, IDisposable, Promise, ServiceEvent } from "../common/Exports"; import { CancellationErrorCode, CancellationReason, Recognizer, SpeechRecognitionResult, SpeechRecognitionResultCustom } from "../sdk/Exports"; import { Callback } from "../sdk/Transcription/IConversation"; import { AgentConfig, DynamicGrammarBuilder, RecognitionMode, RequestSession, SpeechContext } from "./Exports"; import { IAuthentication } from "./IAuthentication"; import { IConnectionFactory } from "./IConnectionFactory"; import { RecognizerConfig } from "./RecognizerConfig"; import { SpeechConnectionMessage } from "./SpeechConnectionMessage.Internal"; export declare abstract class ServiceRecognizerBase implements IDisposable { private privAuthentication; private privConnectionFactory; private privAudioSource; private privConnectionConfigurationPromise; private privConnectionPromise; private privAuthFetchEventId; private privIsDisposed; private privMustReportEndOfStream; private privConnectionEvents; private privServiceEvents; private privDynamicGrammar; private privAgentConfig; private privServiceHasSentMessage; private privActivityTemplate; private privSetTimeout; protected privSpeechContext: SpeechContext; protected privRequestSession: RequestSession; protected privConnectionId: string; protected privRecognizerConfig: RecognizerConfig; protected privRecognizer: Recognizer; protected privSuccessCallback: (e: SpeechRecognitionResult | SpeechRecognitionResultCustom) => void; protected privErrorCallback: (e: string) => void; constructor(authentication: IAuthentication, connectionFactory: IConnectionFactory, audioSource: IAudioSource, recognizerConfig: RecognizerConfig, recognizer: Recognizer); get audioSource(): IAudioSource; get speechContext(): SpeechContext; get dynamicGrammar(): DynamicGrammarBuilder; get agentConfig(): AgentConfig; set conversationTranslatorToken(token: string); isDisposed(): boolean; dispose(reason?: string): void; get connectionEvents(): EventSource<ConnectionEvent>; get serviceEvents(): EventSource<ServiceEvent>; get recognitionMode(): RecognitionMode; protected recognizeOverride: (recoMode: RecognitionMode, sc: (e: SpeechRecognitionResult) => void, ec: (e: string) => void) => any; recognize(recoMode: RecognitionMode, successCallback: (e: SpeechRecognitionResult) => void, errorCallBack: (e: string) => void): Promise<boolean>; stopRecognizing(): Promise<boolean>; connect(): void; connectAsync(cb?: Callback, err?: Callback): void; protected disconnectOverride: () => any; disconnect(): void; disconnectAsync(cb?: Callback, err?: Callback): void; static telemetryData: (json: string) => void; static telemetryDataEnabled: boolean; sendMessage(message: string): void; sendNetworkMessage(path: string, payload: string | ArrayBuffer, success?: () => void, err?: (error: string) => void): void; set activityTemplate(messagePayload: string); get activityTemplate(): string; protected abstract processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage, successCallback?: (e: SpeechRecognitionResult) => void, errorCallBack?: (e: string) => void): boolean; protected sendTelemetryData: () => Promise<boolean> | Promise<Promise<boolean>>; protected abstract cancelRecognition(sessionId: string, requestId: string, cancellationReason: CancellationReason, errorCode: CancellationErrorCode, error: string): void; protected cancelRecognitionLocal(cancellationReason: CancellationReason, errorCode: CancellationErrorCode, error: string): void; protected receiveMessageOverride: () => any; protected receiveMessage: () => Promise<IConnection>; protected sendSpeechContext: (connection: IConnection) => Promise<boolean>; protected sendWaveHeader(connection: IConnection): Promise<boolean>; protected connectImplOverride: (isUnAuthorized: boolean) => any; protected connectImpl(isUnAuthorized?: boolean): Promise<IConnection>; protected configConnectionOverride: () => any; protected fetchConnectionOverride: () => any; protected sendSpeechServiceConfig: (connection: IConnection, requestSession: RequestSession, SpeechServiceConfigJson: string) => Promise<boolean>; protected sendAudio: (audioStreamNode: IAudioStreamNode) => Promise<boolean>; private writeBufferToConsole; private sendFinalAudio; private fetchConnection; private configureConnection; }