UNPKG

hip1-microsoft-cognitiveservices-speech-sdk

Version:
130 lines (129 loc) 6.58 kB
import { ConnectionEvent, EventSource, IAudioSource, IAudioStreamNode, IConnection, IDisposable, ServiceEvent } from "../common/Exports.js"; import { SpeakerRecognitionModel } from "../sdk/SpeakerRecognitionModel.js"; import { CancellationErrorCode, CancellationReason, Recognizer, SpeakerRecognitionResult, SpeechRecognitionResult } from "../sdk/Exports.js"; import { Callback } from "../sdk/Transcription/IConversation.js"; import { AgentConfig, DynamicGrammarBuilder, RecognitionMode, RequestSession, SpeechContext } from "./Exports.js"; import { IAuthentication } from "./IAuthentication.js"; import { IConnectionFactory } from "./IConnectionFactory.js"; import { RecognizerConfig } from "./RecognizerConfig.js"; import { SpeechConnectionMessage } from "./SpeechConnectionMessage.Internal.js"; interface CustomModel { language: string; endpoint: string; } export interface PhraseDetection { customModels?: CustomModel[]; onInterim?: { action: string; }; onSuccess?: { action: string; }; mode?: string; INTERACTIVE?: Segmentation; CONVERSATION?: Segmentation; DICTATION?: Segmentation; speakerDiarization?: SpeakerDiarization; } export interface SpeakerDiarization { mode?: string; audioSessionId?: string; audioOffsetMs?: number; identityProvider?: string; diarizeIntermediates?: boolean; } export interface Segmentation { segmentation: { mode: string; segmentationSilenceTimeoutMs?: number; segmentationForcedTimeoutMs?: number; }; } export declare abstract class ServiceRecognizerBase implements IDisposable { private privAuthentication; private privConnectionFactory; private privConnectionConfigurationPromise; private privConnectionPromise; private privAuthFetchEventId; private privIsDisposed; private privMustReportEndOfStream; private privConnectionEvents; private privServiceEvents; private privDynamicGrammar; private privAgentConfig; private privServiceHasSentMessage; private privActivityTemplate; private privSetTimeout; private privAudioSource; private privIsLiveAudio; private privAverageBytesPerMs; protected privSpeechContext: SpeechContext; protected privRequestSession: RequestSession; protected privConnectionId: string; protected privDiarizationSessionId: string; protected privRecognizerConfig: RecognizerConfig; protected privRecognizer: Recognizer; protected privSuccessCallback: (e: SpeechRecognitionResult) => void; protected privErrorCallback: (e: string) => void; protected privEnableSpeakerId: boolean; protected privExpectContentAssessmentResponse: boolean; constructor(authentication: IAuthentication, connectionFactory: IConnectionFactory, audioSource: IAudioSource, recognizerConfig: RecognizerConfig, recognizer: Recognizer); protected setTranslationJson(): void; protected setSpeechSegmentationTimeoutJson(): void; protected setLanguageIdJson(): void; protected setOutputDetailLevelJson(): void; get isSpeakerDiarizationEnabled(): boolean; get audioSource(): IAudioSource; get speechContext(): SpeechContext; get dynamicGrammar(): DynamicGrammarBuilder; get agentConfig(): AgentConfig; set conversationTranslatorToken(token: string); set voiceProfileType(type: string); set authentication(auth: IAuthentication); isDisposed(): boolean; dispose(reason?: string): Promise<void>; get connectionEvents(): EventSource<ConnectionEvent>; get serviceEvents(): EventSource<ServiceEvent>; get recognitionMode(): RecognitionMode; protected recognizeOverride: (recoMode: RecognitionMode, sc: (e: SpeechRecognitionResult) => void, ec: (e: string) => void) => Promise<void>; recognizeSpeaker: (model: SpeakerRecognitionModel) => Promise<SpeakerRecognitionResult>; recognize(recoMode: RecognitionMode, successCallback: (e: SpeechRecognitionResult) => void, errorCallBack: (e: string) => void): Promise<void>; stopRecognizing(): Promise<void>; connect(): Promise<void>; connectAsync(cb?: Callback, err?: Callback): void; protected disconnectOverride: () => Promise<void>; disconnect(): Promise<void>; static telemetryData: (json: string) => void; static telemetryDataEnabled: boolean; sendMessage(message: string): Promise<void>; sendNetworkMessage(path: string, payload: string | ArrayBuffer): Promise<void>; set activityTemplate(messagePayload: string); get activityTemplate(): string; set expectContentAssessmentResponse(value: boolean); protected abstract processTypeSpecificMessages(connectionMessage: SpeechConnectionMessage, successCallback?: (e: SpeechRecognitionResult) => void, errorCallBack?: (e: string) => void): Promise<boolean>; protected sendTelemetryData(): Promise<void>; protected abstract cancelRecognition(sessionId: string, requestId: string, cancellationReason: CancellationReason, errorCode: CancellationErrorCode, error: string): void; protected cancelRecognitionLocal(cancellationReason: CancellationReason, errorCode: CancellationErrorCode, error: string): Promise<void>; protected receiveMessageOverride: () => Promise<void>; protected receiveMessage(): Promise<void>; private updateSpeakerDiarizationAudioOffset; protected sendSpeechContext(connection: IConnection, generateNewRequestId: boolean): Promise<void>; protected sendPrePayloadJSONOverride: (connection: IConnection) => Promise<void>; protected noOp(): Promise<void>; protected sendPrePayloadJSON(connection: IConnection, generateNewRequestId?: boolean): Promise<void>; protected sendWaveHeader(connection: IConnection): Promise<void>; protected postConnectImplOverride: (connection: Promise<IConnection>) => Promise<IConnection>; protected connectImpl(): Promise<IConnection>; protected configConnectionOverride: (connection: IConnection) => Promise<IConnection>; protected handleSpeechPhraseMessage: (textBody: string) => Promise<void>; protected handleSpeechHypothesisMessage: (textBody: string) => void; protected sendSpeechServiceConfig(connection: IConnection, requestSession: RequestSession, SpeechServiceConfigJson: string): Promise<void>; protected fetchConnection(): Promise<IConnection>; protected sendAudio(audioStreamNode: IAudioStreamNode): Promise<void>; private retryableConnect; private delay; private writeBufferToConsole; private sendFinalAudio; private configureConnection; } export {};