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EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAI7D;;;;;OAKG;IACI,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAIxC;;;;;OAKG;IACI,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC;;;;;OAKG;aACQ,MAAM,EAAI,WAAW,CAAC,gBAAgB,CAAC;IAI3C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAW9C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;aAU3C,UAAU,EAAI,OAAO,CAAC,wBAAwB,CAAC;CAG7D","file":"AudioConfig.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { AudioStreamFormat } from \"../../../src/sdk/Exports\";\nimport { FileAudioSource, MicAudioSource, PcmRecorder } from \"../../common.browser/Exports\";\nimport { ISpeechConfigAudioDevice } from \"../../common.speech/Exports\";\nimport { AudioSourceEvent, EventSource, IAudioSource, IAudioStreamNode, Promise } from \"../../common/Exports\";\nimport { Contracts } from \"../Contracts\";\nimport { AudioInputStream, PropertyCollection, PropertyId, PullAudioInputStreamCallback } from \"../Exports\";\nimport { bufferSize, PullAudioInputStreamImpl, PushAudioInputStreamImpl } from \"./AudioInputStream\";\n\n/**\n * Represents audio input configuration used for specifying what type of input to use (microphone, file, stream).\n * @class AudioConfig\n */\nexport abstract class AudioConfig {\n    /**\n     * Creates an AudioConfig object representing the default microphone on the system.\n     * @member AudioConfig.fromDefaultMicrophoneInput\n     * @function\n     * @public\n     * @returns {AudioConfig} The audio input configuration being created.\n     */\n    public static fromDefaultMicrophoneInput(): AudioConfig {\n        const pcmRecorder = new PcmRecorder();\n        return new AudioConfigImpl(new MicAudioSource(pcmRecorder, bufferSize));\n    }\n\n    /**\n     * Creates an AudioConfig object representing a microphone with the specified device ID.\n     * @member AudioConfig.fromMicrophoneInput\n     * @function\n     * @public\n     * @param {string | undefined} deviceId - Specifies the device ID of the microphone to be used.\n     *        Default microphone is used the value is omitted.\n     * @returns {AudioConfig} The audio input configuration being created.\n     */\n    public static fromMicrophoneInput(deviceId?: string): AudioConfig {\n        const pcmRecorder = new PcmRecorder();\n        return new AudioConfigImpl(new MicAudioSource(pcmRecorder, bufferSize, deviceId));\n    }\n\n    /**\n     * Creates an AudioConfig object representing the specified file.\n     * @member AudioConfig.fromWavFileInput\n     * @function\n     * @public\n     * @param {File} fileName - Specifies the audio input file. Currently, only WAV / PCM with 16-bit\n     *        samples, 16 kHz sample rate, and a single channel (Mono) is supported.\n     * @returns {AudioConfig} The audio input configuration being created.\n     */\n    public static fromWavFileInput(file: File): AudioConfig {\n        return new AudioConfigImpl(new FileAudioSource(file));\n    }\n\n    /**\n     * Creates an AudioConfig object representing the specified stream.\n     * @member AudioConfig.fromStreamInput\n     * @function\n     * @public\n     * @param {AudioInputStream | PullAudioInputStreamCallback} audioStream - Specifies the custom audio input\n     *        stream. Currently, only WAV / PCM with 16-bit samples, 16 kHz sample rate, and a single channel\n     *        (Mono) is supported.\n     * @returns {AudioConfig} The audio input configuration being created.\n     */\n    public static fromStreamInput(audioStream: AudioInputStream | PullAudioInputStreamCallback): AudioConfig {\n        if (audioStream instanceof PullAudioInputStreamCallback) {\n            return new AudioConfigImpl(new PullAudioInputStreamImpl(audioStream as PullAudioInputStreamCallback));\n        }\n\n        if (audioStream instanceof AudioInputStream) {\n            return new AudioConfigImpl(audioStream as PushAudioInputStreamImpl);\n        }\n\n        throw new Error(\"Not Supported Type\");\n    }\n\n    /**\n     * Explicitly frees any external resource attached to the object\n     * @member AudioConfig.prototype.close\n     * @function\n     * @public\n     */\n    public abstract close(): void;\n\n    /**\n     * Sets an arbitrary property.\n     * @member SpeechConfig.prototype.setProperty\n     * @function\n     * @public\n     * @param {string} name - The name of the property to set.\n     * @param {string} value - The new value of the property.\n     */\n    public abstract setProperty(name: string, value: string): void;\n\n    /**\n     * Returns the current value of an arbitrary property.\n     * @member SpeechConfig.prototype.getProperty\n     * @function\n     * @public\n     * @param {string} name - The name of the property to query.\n     * @param {string} def - The value to return in case the property is not known.\n     * @returns {string} The current value, or provided default, of the given property.\n     */\n    public abstract getProperty(name: string, def?: string): string;\n\n}\n\n/**\n * Represents audio input stream used for custom audio input configurations.\n * @private\n * @class AudioConfigImpl\n */\n// tslint:disable-next-line:max-classes-per-file\nexport class AudioConfigImpl extends AudioConfig implements IAudioSource {\n    private privSource: IAudioSource;\n\n    /**\n     * Creates and initializes an instance of this class.\n     * @constructor\n     * @param {IAudioSource} source - An audio source.\n     */\n    public constructor(source: IAudioSource) {\n        super();\n        this.privSource = source;\n    }\n\n    /**\n     * Format information for the audio\n     */\n    public get format(): AudioStreamFormat {\n        return this.privSource.format;\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.close\n     * @function\n     * @public\n     */\n    public close(): void {\n        this.privSource.turnOff();\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.id\n     * @function\n     * @public\n     */\n    public id(): string {\n        return this.privSource.id();\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.turnOn\n     * @function\n     * @public\n     * @returns {Promise<boolean>} A promise.\n     */\n    public turnOn(): Promise<boolean> {\n        return this.privSource.turnOn();\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.attach\n     * @function\n     * @public\n     * @param {string} audioNodeId - The audio node id.\n     * @returns {Promise<IAudioStreamNode>} A promise.\n     */\n    public attach(audioNodeId: string): Promise<IAudioStreamNode> {\n        return this.privSource.attach(audioNodeId);\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.detach\n     * @function\n     * @public\n     * @param {string} audioNodeId - The audio node id.\n     */\n    public detach(audioNodeId: string): void {\n        return this.detach(audioNodeId);\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.turnOff\n     * @function\n     * @public\n     * @returns {Promise<boolean>} A promise.\n     */\n    public turnOff(): Promise<boolean> {\n        return this.privSource.turnOff();\n    }\n\n    /**\n     * @member AudioConfigImpl.prototype.events\n     * @function\n     * @public\n     * @returns {EventSource<AudioSourceEvent>} An event source for audio events.\n     */\n    public get events(): EventSource<AudioSourceEvent> {\n        return this.privSource.events;\n    }\n\n    public setProperty(name: string, value: string): void {\n        Contracts.throwIfNull(value, \"value\");\n\n        if (undefined !== this.privSource.setProperty) {\n            this.privSource.setProperty(name, value);\n        } else {\n            throw new Error(\"This AudioConfig instance does not support setting properties.\");\n        }\n\n    }\n\n    public getProperty(name: string, def?: string): string {\n        if (undefined !== this.privSource.getProperty) {\n            return this.privSource.getProperty(name, def);\n        } else {\n            throw new Error(\"This AudioConfig instance does not support getting properties.\");\n        }\n\n        return def;\n    }\n\n    public get deviceInfo(): Promise<ISpeechConfigAudioDevice> {\n        return this.privSource.deviceInfo;\n    }\n}\n"]}