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E,IAAI,MAAM;IAIZ,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAI9C,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM;CAGzD","file":"AudioConfig.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { PathLike } from \"fs\";\nimport {\n    FileAudioSource,\n    MicAudioSource,\n    PcmRecorder,\n} from \"../../common.browser/Exports\";\nimport { ISpeechConfigAudioDevice } from \"../../common.speech/Exports\";\nimport {\n    AudioSourceEvent,\n    Deferred,\n    EventSource,\n    IAudioDestination,\n    IAudioSource,\n    IAudioStreamNode,\n    Promise\n} from \"../../common/Exports\";\nimport { Contracts } from \"../Contracts\";\nimport {\n    AudioInputStream,\n    AudioOutputStream,\n    AudioStreamFormat,\n    IPlayer,\n    PropertyCollection,\n    PropertyId,\n    PullAudioInputStreamCallback,\n    PullAudioOutputStream,\n    PushAudioOutputStream,\n    PushAudioOutputStreamCallback,\n    SpeakerAudioDestination\n} from \"../Exports\";\nimport { AudioFileWriter } from \"./AudioFileWriter\";\nimport { PullAudioInputStreamImpl, PushAudioInputStreamImpl } from \"./AudioInputStream\";\nimport { PullAudioOutputStreamImpl, PushAudioOutputStreamImpl } from \"./AudioOutputStream\";\nimport { AudioStreamFormatImpl } from \"./AudioStreamFormat\";\n\n/**\n * Represents audio input configuration used for specifying what type of input to use (microphone, file, stream).\n * @class AudioConfig\n * Updated in version 1.11.0\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));\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, 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 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 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     * Creates an AudioConfig object representing the default speaker.\n     * @member AudioConfig.fromDefaultSpeakerOutput\n     * @function\n     * @public\n     * @returns {AudioConfig} The audio output configuration being created.\n     * Added in version 1.11.0\n     */\n    public static fromDefaultSpeakerOutput(): AudioConfig {\n        return new AudioOutputConfigImpl(new SpeakerAudioDestination());\n    }\n\n    /**\n     * Creates an AudioConfig object representing the custom IPlayer object.\n     * You can use the IPlayer object to control pause, resume, etc.\n     * @member AudioConfig.fromSpeakerOutput\n     * @function\n     * @public\n     * @param {IPlayer} player - the IPlayer object for playback.\n     * @returns {AudioConfig} The audio output configuration being created.\n     * Added in version 1.12.0\n     */\n    public static fromSpeakerOutput(player?: IPlayer): AudioConfig {\n        if (player === undefined) {\n            return AudioConfig.fromDefaultSpeakerOutput();\n        }\n        if (player instanceof SpeakerAudioDestination) {\n            return new AudioOutputConfigImpl(player as SpeakerAudioDestination);\n        }\n\n        throw new Error(\"Not Supported Type\");\n    }\n\n    /**\n     * Creates an AudioConfig object representing a specified output audio file\n     * @member AudioConfig.fromAudioFileOutput\n     * @function\n     * @public\n     * @param {PathLike} filename - the filename of the output audio file\n     * @returns {AudioConfig} The audio output configuration being created.\n     * Added in version 1.11.0\n     */\n    public static fromAudioFileOutput(filename: PathLike): AudioConfig {\n        return new AudioOutputConfigImpl(new AudioFileWriter(filename));\n    }\n\n    /**\n     * Creates an AudioConfig object representing a specified audio output stream\n     * @member AudioConfig.fromStreamOutput\n     * @function\n     * @public\n     * @param {AudioOutputStream | PushAudioOutputStreamCallback} audioStream - Specifies the custom audio output\n     *        stream.\n     * @returns {AudioConfig} The audio output configuration being created.\n     * Added in version 1.11.0\n     */\n    public static fromStreamOutput(audioStream: AudioOutputStream | PushAudioOutputStreamCallback): AudioConfig {\n        if (audioStream instanceof PushAudioOutputStreamCallback) {\n            return new AudioOutputConfigImpl(new PushAudioOutputStreamImpl(audioStream as PushAudioOutputStreamCallback));\n        }\n\n        if (audioStream instanceof PushAudioOutputStream) {\n            return new AudioOutputConfigImpl(audioStream as PushAudioOutputStreamImpl);\n        }\n\n        if (audioStream instanceof PullAudioOutputStream) {\n            return new AudioOutputConfigImpl(audioStream as PullAudioOutputStreamImpl);\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(): Promise<AudioStreamFormatImpl> {\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.blob\n     * @function\n     * @public\n     */\n    public get blob(): Promise<Blob | Buffer> {\n        return this.privSource.blob;\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.privSource.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\n// tslint:disable-next-line:max-classes-per-file\nexport class AudioOutputConfigImpl extends AudioConfig implements IAudioDestination {\n    private privDestination: IAudioDestination;\n\n    /**\n     * Creates and initializes an instance of this class.\n     * @constructor\n     * @param {IAudioDestination} destination - An audio destination.\n     */\n    public constructor(destination: IAudioDestination) {\n        super();\n        this.privDestination = destination;\n    }\n\n    public set format(format: AudioStreamFormat) {\n        this.privDestination.format = format;\n    }\n\n    public write(buffer: ArrayBuffer): void {\n        this.privDestination.write(buffer);\n    }\n\n    public close(): void {\n        this.privDestination.close();\n    }\n\n    public id(): string {\n        return this.privDestination.id();\n    }\n\n    public setProperty(name: string, value: string): void {\n        throw new Error(\"This AudioConfig instance does not support setting properties.\");\n    }\n\n    public getProperty(name: string, def?: string): string {\n        throw new Error(\"This AudioConfig instance does not support getting properties.\");\n    }\n}\n"]}