microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 11.9 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/Transcription/MeetingTranscriber.ts"],"names":[],"mappings":"AAMA,OAAO,EACH,WAAW,EACX,qBAAqB,EACrB,UAAU,EACV,6BAA6B,EAC7B,kBAAkB,EAElB,gBAAgB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,cAAc,EAEd,2BAA2B,EAC9B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEnD,qBAAa,kBAAmB,YAAW,2BAA2B;IAElE;;;;;OAKG;IACI,eAAe,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAEvF;;;;;OAKG;IACI,QAAQ,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAE/E;;;;;OAKG;IACG,WAAW,EAAE,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,6BAA6B,KAAK,IAAI,CAAC;IAEvG;;;;;OAKG;IACG,YAAY,EAAE,CAAC,MAAM,EAAE,2BAA2B,EAAE,KAAK,EAAE,6BAA6B,KAAK,IAAI,CAAC;IAEzG;;;;;OAKG;IACI,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEjF;;;;;OAKG;IACI,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEjF;;;;;OAKG;IACI,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAEjF;;;;;OAKG;IACI,cAAc,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,gBAA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scriber.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport { TranscriberRecognizer } from \"../../common.speech/Exports.js\";\r\nimport { marshalPromiseToCallbacks } from \"../../common/Exports.js\";\r\nimport { Contracts } from \"../Contracts.js\";\r\nimport {\r\n AudioConfig,\r\n CancellationEventArgs,\r\n Connection,\r\n MeetingTranscriptionEventArgs,\r\n PropertyCollection,\r\n PropertyId,\r\n SessionEventArgs\r\n} from \"../Exports.js\";\r\nimport {\r\n MeetingHandler,\r\n MeetingImpl,\r\n MeetingTranscriptionHandler\r\n} from \"./Exports.js\";\r\nimport { Callback, IMeeting } from \"./IMeeting.js\";\r\n\r\nexport class MeetingTranscriber implements MeetingTranscriptionHandler {\r\n\r\n /**\r\n * The event canceled signals that an error occurred during the meeting.\r\n * @member MeetingTranscriber.prototype.MeetingCanceled\r\n * @function\r\n * @public\r\n */\r\n public MeetingCanceled: (sender: MeetingHandler, event: CancellationEventArgs) => void;\r\n\r\n /**\r\n * The event canceled signals that an error occurred during transcription.\r\n * @member MeetingTranscriber.prototype.canceled\r\n * @function\r\n * @public\r\n */\r\n public canceled: (sender: MeetingHandler, event: CancellationEventArgs) => void;\r\n\r\n /**\r\n * The event recognized signals that a final meeting transcription result is received.\r\n * @member MeetingTranscriber.prototype.transcribed\r\n * @function\r\n * @public\r\n */\r\n public transcribed: (sender: MeetingTranscriptionHandler, event: MeetingTranscriptionEventArgs) => void;\r\n\r\n /**\r\n * The event recognizing signals that an intermediate meeting transcription result is received.\r\n * @member MeetingTranscriber.prototype.transcribing\r\n * @function\r\n * @public\r\n */\r\n public transcribing: (sender: MeetingTranscriptionHandler, event: MeetingTranscriptionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for session started events.\r\n * @member MeetingTranscriber.prototype.sessionStarted\r\n * @function\r\n * @public\r\n */\r\n public sessionStarted: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for session stopped events.\r\n * @member MeetingTranscriber.prototype.sessionStopped\r\n * @function\r\n * @public\r\n */\r\n public sessionStopped: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for meeting started events.\r\n * @member MeetingTranscriber.prototype.MeetingStarted\r\n * @function\r\n * @public\r\n */\r\n public MeetingStarted: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n /**\r\n * Defines event handler for meeting stopped events.\r\n * @member MeetingTranscriber.prototype.MeetingStopped\r\n * @function\r\n * @public\r\n */\r\n public meetingStopped: (sender: MeetingHandler, event: SessionEventArgs) => void;\r\n\r\n protected privAudioConfig: AudioConfig;\r\n private privDisposedRecognizer: boolean;\r\n private privRecognizer: TranscriberRecognizer;\r\n private privProperties: PropertyCollection;\r\n\r\n /**\r\n * MeetingTranscriber constructor.\r\n * @constructor\r\n * @param {AudioConfig} audioConfig - An optional audio configuration associated with the recognizer\r\n */\r\n public constructor(audioConfig?: AudioConfig) {\r\n this.privAudioConfig = audioConfig;\r\n this.privProperties = new PropertyCollection();\r\n this.privRecognizer = undefined;\r\n this.privDisposedRecognizer = false;\r\n }\r\n\r\n /**\r\n * Gets the spoken language of recognition.\r\n * @member MeetingTranscriber.prototype.speechRecognitionLanguage\r\n * @function\r\n * @public\r\n * @returns {string} The spoken language of recognition.\r\n */\r\n public get speechRecognitionLanguage(): string {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n\r\n return this.properties.getProperty(PropertyId.SpeechServiceConnection_RecoLanguage);\r\n }\r\n\r\n /**\r\n * The collection of properties and their values defined for this MeetingTranscriber.\r\n * @member MeetingTranscriber.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this MeetingTranscriber.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * @Internal\r\n * Internal data member to support fromRecognizer* pattern methods on other classes.\r\n * Do not use externally, object returned will change without warning or notice.\r\n */\r\n public get internalData(): object {\r\n return this.privRecognizer.internalData;\r\n }\r\n\r\n /**\r\n * @Deprecated\r\n * @Obsolete\r\n * Please use the Connection.fromRecognizer pattern to obtain a connection object\r\n */\r\n public get connection(): Connection {\r\n return Connection.fromRecognizer(this.privRecognizer);\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member MeetingTranscriber.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @returns {string} Authorization token.\r\n */\r\n public get authorizationToken(): string {\r\n return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\r\n }\r\n\r\n /**\r\n * Gets/Sets the authorization token used to communicate with the service.\r\n * @member MeetingTranscriber.prototype.authorizationToken\r\n * @function\r\n * @public\r\n * @param {string} token - Authorization token.\r\n */\r\n public set authorizationToken(token: string) {\r\n Contracts.throwIfNullOrWhitespace(token, \"token\");\r\n this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\r\n }\r\n\r\n /**\r\n * @param {Meeting} meeting - meeting to be recognized\r\n */\r\n public joinMeetingAsync(meeting: IMeeting, cb?: Callback, err?: Callback): void {\r\n /* eslint-disable no-console */\r\n // console.log(\">> MeetingTranscriber::joinMeetingAsync\");\r\n /* eslint-enable no-console */\r\n const meetingImpl = meeting as MeetingImpl;\r\n Contracts.throwIfNullOrUndefined(MeetingImpl, \"Meeting\");\r\n\r\n // ref the meeting object\r\n // create recognizer and subscribe to recognizer events\r\n this.privRecognizer = new TranscriberRecognizer(meeting.config, this.privAudioConfig);\r\n Contracts.throwIfNullOrUndefined(this.privRecognizer, \"Recognizer\");\r\n this.privRecognizer.connectMeetingCallbacks(this);\r\n\r\n marshalPromiseToCallbacks(meetingImpl.connectTranscriberRecognizer(this.privRecognizer), cb, err);\r\n }\r\n\r\n /**\r\n * Starts meeting transcription, until stopTranscribingAsync() is called.\r\n * User must subscribe to events to receive transcription results.\r\n * @member MeetingTranscriber.prototype.startTranscribingAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the transcription has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public startTranscribingAsync(cb?: Callback, err?: Callback): void {\r\n this.privRecognizer.startContinuousRecognitionAsync(cb, err);\r\n }\r\n\r\n /**\r\n * Starts meeting transcription, until stopTranscribingAsync() is called.\r\n * User must subscribe to events to receive transcription results.\r\n * @member MeetingTranscriber.prototype.stopTranscribingAsync\r\n * @function\r\n * @public\r\n * @param cb - Callback invoked once the transcription has started.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public stopTranscribingAsync(cb?: Callback, err?: Callback): void {\r\n this.privRecognizer.stopContinuousRecognitionAsync(cb, err);\r\n }\r\n\r\n /**\r\n * Leave the current meeting. After this is called, you will no longer receive any events.\r\n */\r\n public leaveMeetingAsync(cb?: Callback, err?: Callback): void {\r\n this.privRecognizer.disconnectCallbacks();\r\n // eslint-disable-next-line\r\n marshalPromiseToCallbacks((async (): Promise<void> => { return; })(), cb, err);\r\n }\r\n\r\n /**\r\n * closes all external resources held by an instance of this class.\r\n * @member MeetingTranscriber.prototype.close\r\n * @function\r\n * @public\r\n */\r\n public close(cb?: () => void, errorCb?: (error: string) => void): void {\r\n Contracts.throwIfDisposed(this.privDisposedRecognizer);\r\n marshalPromiseToCallbacks(this.dispose(true), cb, errorCb);\r\n }\r\n\r\n /**\r\n * Disposes any resources held by the object.\r\n * @member MeetingTranscriber.prototype.dispose\r\n * @function\r\n * @public\r\n * @param {boolean} disposing - true if disposing the object.\r\n */\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedRecognizer) {\r\n return;\r\n }\r\n if (!!this.privRecognizer) {\r\n await this.privRecognizer.close();\r\n this.privRecognizer = undefined;\r\n }\r\n if (disposing) {\r\n this.privDisposedRecognizer = true;\r\n }\r\n }\r\n}\r\n"]}