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E,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.\n// Licensed under the MIT license.\n\nimport {\n    IAuthentication,\n    IConnectionFactory,\n    RecognizerConfig,\n    ServiceRecognizerBase,\n    SpeakerRecognitionConnectionFactory,\n    SpeakerServiceRecognizer,\n    SpeechServiceConfig\n} from \"../common.speech/Exports.js\";\nimport { SpeakerRecognitionModel } from \"./SpeakerRecognitionModel.js\";\nimport { AudioConfig, AudioConfigImpl } from \"./Audio/AudioConfig.js\";\nimport { Contracts } from \"./Contracts.js\";\nimport {\n    PropertyCollection,\n    PropertyId,\n    Recognizer,\n    SpeakerIdentificationModel,\n    SpeakerRecognitionResult,\n    SpeakerVerificationModel,\n} from \"./Exports.js\";\nimport { SpeechConfig, SpeechConfigImpl } from \"./SpeechConfig.js\";\n\n/**\n * Defines SpeakerRecognizer class for Speaker Recognition\n * Handles operations from user for Voice Profile operations (e.g. createProfile, deleteProfile)\n * @class SpeakerRecognizer\n */\nexport class SpeakerRecognizer extends Recognizer {\n    protected privProperties: PropertyCollection;\n    private privDisposedSpeakerRecognizer: boolean;\n    private privAudioConfigImpl: AudioConfigImpl;\n    /**\n     * Initializes an instance of the SpeakerRecognizer.\n     * @constructor\n     * @param {SpeechConfig} speechConfig - The set of configuration properties.\n     * @param {AudioConfig} audioConfig - An optional audio input config associated with the recognizer\n     */\n    public constructor(speechConfig: SpeechConfig, audioConfig: AudioConfig) {\n        Contracts.throwIfNullOrUndefined(speechConfig, \"speechConfig\");\n        const configImpl: SpeechConfigImpl = speechConfig as SpeechConfigImpl;\n        Contracts.throwIfNullOrUndefined(configImpl, \"speechConfig\");\n\n        super(audioConfig, configImpl.properties, new SpeakerRecognitionConnectionFactory());\n        this.privAudioConfigImpl = audioConfig as AudioConfigImpl;\n        Contracts.throwIfNull(this.privAudioConfigImpl, \"audioConfig\");\n\n        this.privDisposedSpeakerRecognizer = false;\n        this.privProperties = configImpl.properties;\n    }\n\n    /**\n     * Gets the authorization token used to communicate with the service.\n     * @member SpeakerRecognizer.prototype.authorizationToken\n     * @function\n     * @public\n     * @returns {string} Authorization token.\n     */\n    public get authorizationToken(): string {\n        return this.properties.getProperty(PropertyId.SpeechServiceAuthorization_Token);\n    }\n\n    /**\n     * Gets/Sets the authorization token used to communicate with the service.\n     * @member SpeakerRecognizer.prototype.authorizationToken\n     * @function\n     * @public\n     * @param {string} token - Authorization token.\n     */\n    public set authorizationToken(token: string) {\n        Contracts.throwIfNullOrWhitespace(token, \"token\");\n        this.properties.setProperty(PropertyId.SpeechServiceAuthorization_Token, token);\n    }\n\n    /**\n     * The collection of properties and their values defined for this SpeakerRecognizer.\n     * @member SpeakerRecognizer.prototype.properties\n     * @function\n     * @public\n     * @returns {PropertyCollection} The collection of properties and their values defined for this SpeakerRecognizer.\n     */\n    public get properties(): PropertyCollection {\n        return this.privProperties;\n    }\n\n    /**\n     * Get recognition result for model using given audio\n     * @member SpeakerRecognizer.prototype.recognizeOnceAsync\n     * @function\n     * @public\n     * @async\n     * @param {SpeakerIdentificationModel | SpeakerVerificationModel} model Model containing Voice Profiles to be identified\n     * @param cb - Callback invoked once result is returned.\n     * @param err - Callback invoked in case of an error.\n     */\n    public async recognizeOnceAsync(model: SpeakerIdentificationModel | SpeakerVerificationModel): Promise<SpeakerRecognitionResult> {\n        Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\n\n        return this.recognizeSpeakerOnceAsyncImpl(model);\n    }\n\n    /**\n     * Included for compatibility\n     * @member SpeakerRecognizer.prototype.close\n     * @function\n     * @public\n     * @async\n     */\n    public async close(): Promise<void> {\n        Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\n        await this.dispose(true);\n    }\n\n    protected async recognizeSpeakerOnceAsyncImpl(model: SpeakerRecognitionModel): Promise<SpeakerRecognitionResult> {\n        Contracts.throwIfDisposed(this.privDisposedSpeakerRecognizer);\n\n        await this.implRecognizerStop();\n        const result: SpeakerRecognitionResult = await this.privReco.recognizeSpeaker(model);\n        await this.implRecognizerStop();\n\n        return result;\n    }\n\n    protected async implRecognizerStop(): Promise<void> {\n        if (this.privReco) {\n            await this.privReco.stopRecognizing();\n        }\n        return;\n    }\n\n    protected createRecognizerConfig(speechConfig: SpeechServiceConfig): RecognizerConfig {\n        return new RecognizerConfig(speechConfig, this.privProperties);\n    }\n\n    protected createServiceRecognizer(authentication: IAuthentication, connectionFactory: IConnectionFactory, audioConfig: AudioConfig, recognizerConfig: RecognizerConfig): ServiceRecognizerBase {\n        const audioImpl: AudioConfigImpl = audioConfig as AudioConfigImpl;\n        return new SpeakerServiceRecognizer(authentication, connectionFactory, audioImpl, recognizerConfig, this);\n    }\n\n    protected async dispose(disposing: boolean): Promise<void> {\n        if (this.privDisposedSpeakerRecognizer) {\n            return;\n        }\n\n        if (disposing) {\n            this.privDisposedSpeakerRecognizer = true;\n            await super.dispose(disposing);\n        }\n    }\n}\n"]}