UNPKG

@euirim/microsoft-cognitiveservices-speech-sdk

Version:
1 lines 5.23 kB
{"version":3,"sources":["src/sdk/Audio/AudioStreamFormat.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,8BAAsB,iBAAiB;IACnC;;;;;;;OAOG;WACW,qBAAqB,IAAI,iBAAiB;IAIxD;;;;;;;;;;OAUG;WACW,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB;IAIpH;;;;;OAKG;aACa,KAAK,IAAI,IAAI;CAChC;AAED;;;GAGG;AAEH,qBAAa,qBAAsB,SAAQ,iBAAiB;IACxD;;;;;;OAMG;gBACgB,aAAa,GAAE,MAAc,EAAE,aAAa,GAAE,MAAW,EAAE,QAAQ,GAAE,MAAU;IAUlG;;;;;;OAMG;WACW,qBAAqB,IAAI,qBAAqB;IAI5D;;;;;OAKG;IACI,KAAK,IAAI,IAAI;IAEpB;;;;;OAKG;IACI,SAAS,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;IACI,QAAQ,EAAE,MAAM,CAAC;IAExB;;;;;OAKG;IACI,aAAa,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACI,aAAa,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACI,cAAc,EAAE,MAAM,CAAC;IAE9B;;;;;OAKG;IACI,UAAU,EAAE,MAAM,CAAC;CAC7B","file":"AudioStreamFormat.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\n/**\n * Represents audio stream format used for custom audio input configurations.\n * @class AudioStreamFormat\n */\nexport abstract class AudioStreamFormat {\n /**\n * Creates an audio stream format object representing the default audio stream\n * format (16KHz 16bit mono PCM).\n * @member AudioStreamFormat.getDefaultInputFormat\n * @function\n * @public\n * @returns {AudioStreamFormat} The audio stream format being created.\n */\n public static getDefaultInputFormat(): AudioStreamFormat {\n return AudioStreamFormatImpl.getDefaultInputFormat();\n }\n\n /**\n * Creates an audio stream format object with the specified pcm waveformat characteristics.\n * @member AudioStreamFormat.getWaveFormatPCM\n * @function\n * @public\n * @param {number} samplesPerSecond - Sample rate, in samples per second (Hertz).\n * @param {number} bitsPerSample - Bits per sample, typically 16.\n * @param {number} channels - Number of channels in the waveform-audio data. Monaural data\n * uses one channel and stereo data uses two channels.\n * @returns {AudioStreamFormat} The audio stream format being created.\n */\n public static getWaveFormatPCM(samplesPerSecond: number, bitsPerSample: number, channels: number): AudioStreamFormat {\n return new AudioStreamFormatImpl(samplesPerSecond, bitsPerSample, channels);\n }\n\n /**\n * Explicitly frees any external resource attached to the object\n * @member AudioStreamFormat.prototype.close\n * @function\n * @public\n */\n public abstract close(): void;\n}\n\n/**\n * @private\n * @class AudioStreamFormatImpl\n */\n// tslint:disable-next-line:max-classes-per-file\nexport class AudioStreamFormatImpl extends AudioStreamFormat {\n /**\n * Creates an instance with the given values.\n * @constructor\n * @param {number} samplesPerSec - Samples per second.\n * @param {number} bitsPerSample - Bits per sample.\n * @param {number} channels - Number of channels.\n */\n public constructor(samplesPerSec: number = 16000, bitsPerSample: number = 16, channels: number = 1) {\n super();\n this.formatTag = 1;\n this.bitsPerSample = bitsPerSample;\n this.samplesPerSec = samplesPerSec;\n this.channels = channels;\n this.avgBytesPerSec = this.samplesPerSec * this.channels * (this.bitsPerSample / 8);\n this.blockAlign = this.channels * Math.max(this.bitsPerSample, 8);\n }\n\n /**\n * Retrieves the default input format.\n * @member AudioStreamFormatImpl.getDefaultInputFormat\n * @function\n * @public\n * @returns {AudioStreamFormatImpl} The default input format.\n */\n public static getDefaultInputFormat(): AudioStreamFormatImpl {\n return new AudioStreamFormatImpl();\n }\n\n /**\n * Closes the configuration object.\n * @member AudioStreamFormatImpl.prototype.close\n * @function\n * @public\n */\n public close(): void { return; }\n\n /**\n * The format of the audio, valid values: 1 (PCM)\n * @member AudioStreamFormatImpl.prototype.formatTag\n * @function\n * @public\n */\n public formatTag: number;\n\n /**\n * The number of channels, valid values: 1 (Mono).\n * @member AudioStreamFormatImpl.prototype.channels\n * @function\n * @public\n */\n public channels: number;\n\n /**\n * The sample rate, valid values: 16000.\n * @member AudioStreamFormatImpl.prototype.samplesPerSec\n * @function\n * @public\n */\n public samplesPerSec: number;\n\n /**\n * The bits per sample, valid values: 16\n * @member AudioStreamFormatImpl.prototype.b\n * @function\n * @public\n */\n public bitsPerSample: number;\n\n /**\n * Average bytes per second, usually calculated as nSamplesPerSec * nChannels * ceil(wBitsPerSample, 8).\n * @member AudioStreamFormatImpl.prototype.avgBytesPerSec\n * @function\n * @public\n */\n public avgBytesPerSec: number;\n\n /**\n * The size of a single frame, valid values: nChannels * ceil(wBitsPerSample, 8).\n * @member AudioStreamFormatImpl.prototype.blockAlign\n * @function\n * @public\n */\n public blockAlign: number;\n}\n"]}