microsoft-cognitiveservices-speech-sdk
Version:
Microsoft Cognitive Services Speech SDK for JavaScript
1 lines • 7.49 kB
Source Map (JSON)
{"version":3,"sources":["src/sdk/SpeakerRecognizer.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EAGrB,mBAAmB,EACtB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,WAAW,EAAmB,MAAM,wBAAwB,CAAC;AAEtE,OAAO,EACH,kBAAkB,EAElB,UAAU,EACV,0BAA0B,EAC1B,wBAAwB,EACxB,wBAAwB,EAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAoB,MAAM,mBAAmB,CAAC;AAEnE;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,UAAU;IAC7C,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAC7C,OAAO,CAAC,6BAA6B,CAAU;IAC/C,OAAO,CAAC,mBAAmB,CAAkB;IAC7C;;;;;OAKG;gBACgB,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW;IAavE;;;;;;OAMG;IACH,IAAW,kBAAkB,IAAI,MAAM,CAEtC;IAED;;;;;;OAMG;IACH,IAAW,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAG1C;IAED;;;;;;OAMG;IACH,IAAW,UAAU,IAAI,kBAAkB,CAE1C;IAED;;;;;;;;;OASG;IACU,kBAAkB,CAAC,KAAK,EAAE,0BAA0B,GAAG,wBAAwB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAMhI;;;;;;OAMG;IACU,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;cAKnB,6BAA6B,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;cAUhG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOnD,SAAS,CAAC,sBAAsB,CAAC,YAAY,EAAE,mBAAmB,GAAG,gBAAgB;IAIrF,SAAS,CAAC,uBAAuB,CAAC,cAAc,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,gBAAgB,GAAG,qBAAqB;cAK9K,OAAO,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAU7D","file":"SpeakerRecognizer.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT license.\r\n\r\nimport {\r\n IAuthentication,\r\n IConnectionFactory,\r\n RecognizerConfig,\r\n ServiceRecognizerBase,\r\n SpeakerRecognitionConnectionFactory,\r\n SpeakerServiceRecognizer,\r\n SpeechServiceConfig\r\n} from \"../common.speech/Exports.js\";\r\nimport { SpeakerRecognitionModel } from \"./SpeakerRecognitionModel.js\";\r\nimport { AudioConfig, AudioConfigImpl } from \"./Audio/AudioConfig.js\";\r\nimport { Contracts } from \"./Contracts.js\";\r\nimport {\r\n PropertyCollection,\r\n PropertyId,\r\n Recognizer,\r\n SpeakerIdentificationModel,\r\n SpeakerRecognitionResult,\r\n SpeakerVerificationModel,\r\n} from \"./Exports.js\";\r\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig.js\";\r\n\r\n/**\r\n * Defines SpeakerRecognizer class for Speaker Recognition\r\n * Handles operations from user for Voice Profile operations (e.g. createProfile, deleteProfile)\r\n * @class SpeakerRecognizer\r\n */\r\nexport class SpeakerRecognizer extends Recognizer {\r\n protected privProperties: PropertyCollection;\r\n private privDisposedSpeakerRecognizer: boolean;\r\n private privAudioConfigImpl: AudioConfigImpl;\r\n /**\r\n * Initializes an instance of the SpeakerRecognizer.\r\n * @constructor\r\n * @param {SpeechConfig} speechConfig - The set of configuration properties.\r\n * @param {AudioConfig} audioConfig - An optional audio input config associated with the recognizer\r\n */\r\n public constructor(speechConfig: SpeechConfig, audioConfig: AudioConfig) {\r\n Contracts.throwIfNullOrUndefined(speechConfig, \"speechConfig\");\r\n const configImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\r\n Contracts.throwIfNullOrUndefined(configImpl, \"speechConfig\");\r\n\r\n super(audioConfig, configImpl.properties, new SpeakerRecognitionConnectionFactory());\r\n this.privAudioConfigImpl = audioConfig as AudioConfigImpl;\r\n Contracts.throwIfNull(this.privAudioConfigImpl, \"audioConfig\");\r\n\r\n this.privDisposedSpeakerRecognizer = false;\r\n this.privProperties = configImpl.properties;\r\n }\r\n\r\n /**\r\n * Gets the authorization token used to communicate with the service.\r\n * @member SpeakerRecognizer.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 SpeakerRecognizer.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 * The collection of properties and their values defined for this SpeakerRecognizer.\r\n * @member SpeakerRecognizer.prototype.properties\r\n * @function\r\n * @public\r\n * @returns {PropertyCollection} The collection of properties and their values defined for this SpeakerRecognizer.\r\n */\r\n public get properties(): PropertyCollection {\r\n return this.privProperties;\r\n }\r\n\r\n /**\r\n * Get recognition result for model using given audio\r\n * @member SpeakerRecognizer.prototype.recognizeOnceAsync\r\n * @function\r\n * @public\r\n * @async\r\n * @param {SpeakerIdentificationModel | SpeakerVerificationModel} model Model containing Voice Profiles to be identified\r\n * @param cb - Callback invoked once result is returned.\r\n * @param err - Callback invoked in case of an error.\r\n */\r\n public async recognizeOnceAsync(model: SpeakerIdentificationModel | SpeakerVerificationModel): Promise<SpeakerRecognitionResult> {\r\n Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\r\n\r\n return this.recognizeSpeakerOnceAsyncImpl(model);\r\n }\r\n\r\n /**\r\n * Included for compatibility\r\n * @member SpeakerRecognizer.prototype.close\r\n * @function\r\n * @public\r\n * @async\r\n */\r\n public async close(): Promise<void> {\r\n Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\r\n await this.dispose(true);\r\n }\r\n\r\n protected async recognizeSpeakerOnceAsyncImpl(model: SpeakerRecognitionModel): Promise<SpeakerRecognitionResult> {\r\n Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\r\n\r\n await this.implRecognizerStop();\r\n const result: SpeakerRecognitionResult = await this.privReco.recognizeSpeaker(model);\r\n await this.implRecognizerStop();\r\n\r\n return result;\r\n }\r\n\r\n protected async implRecognizerStop(): Promise<void> {\r\n if (this.privReco) {\r\n await this.privReco.stopRecognizing();\r\n }\r\n return;\r\n }\r\n\r\n protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\r\n return new RecognizerConfig(speechConfig, this.privProperties);\r\n }\r\n\r\n protected createServiceRecognizer(authentication: IAuthentication, connectionFactory: IConnectionFactory, audioConfig: AudioConfig, recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\r\n const audioImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\r\n return new SpeakerServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\r\n }\r\n\r\n protected async dispose(disposing: boolean): Promise<void> {\r\n if (this.privDisposedSpeakerRecognizer) {\r\n return;\r\n }\r\n\r\n if (disposing) {\r\n this.privDisposedSpeakerRecognizer = true;\r\n await super.dispose(disposing);\r\n }\r\n }\r\n}\r\n"]}