UNPKG

@hahnpro/ms-speech-sdk

Version:
1 lines 27.3 kB
{"version":3,"sources":["src/sdk/Audio/AudioOutputFormat.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/E;;;;GAIG;AAEH,qBAAa,qBAAsB,SAAQ,qBAAqB;IAC5D,OAAc,mCAAmC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAwC1E;IACF,OAAO,CAAC,oBAAoB,CAAS;IACrC;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAS;IACrD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC;;;;;;;;;;;;OAYG;gBACgB,SAAS,EAAE,cAAc,EACzB,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,MAAM,EACzB,wBAAwB,EAAE,MAAM,EAChC,SAAS,EAAE,OAAO;WAUvB,+BAA+B,CAAC,2BAA2B,CAAC,EAAE,2BAA2B,GAAG,qBAAqB;WAQjH,qCAAqC,CAAC,iCAAiC,EAAE,MAAM,GAAG,qBAAqB;WA0cvG,sBAAsB,IAAI,qBAAqB;IAK7D;;;;;OAKG;IACI,SAAS,EAAE,cAAc,CAAC;IAEjC;;;;;OAKG;IACH,IAAW,SAAS,IAAI,OAAO,CAE9B;IAED;;;;;OAKG;IACH,IAAW,MAAM,IAAI,WAAW,CAK/B;IAED;;;;;;OAMG;IACI,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAQ9C;;;;;OAKG;IACH,IAAW,wBAAwB,IAAI,MAAM,CAE5C;IAED;;;;OAIG;IAEI,SAAS,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAWpD","file":"AudioOutputFormat.d.ts","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\n// Licensed under the MIT license.\n\nimport { INumberDictionary } from \"../../common/Exports.js\";\nimport { SpeechSynthesisOutputFormat } from \"../SpeechSynthesisOutputFormat.js\";\nimport { AudioFormatTag, AudioStreamFormatImpl } from \"./AudioStreamFormat.js\";\n\n/**\n * @private\n * @class AudioOutputFormatImpl\n * Updated in version 1.17.0\n */\n// eslint-disable-next-line max-classes-per-file\nexport class AudioOutputFormatImpl extends AudioStreamFormatImpl {\n public static SpeechSynthesisOutputFormatToString: INumberDictionary<string> = {\n [SpeechSynthesisOutputFormat.Raw8Khz8BitMonoMULaw]: \"raw-8khz-8bit-mono-mulaw\",\n [SpeechSynthesisOutputFormat.Riff16Khz16KbpsMonoSiren]: \"riff-16khz-16kbps-mono-siren\",\n [SpeechSynthesisOutputFormat.Audio16Khz16KbpsMonoSiren]: \"audio-16khz-16kbps-mono-siren\",\n [SpeechSynthesisOutputFormat.Audio16Khz32KBitRateMonoMp3]: \"audio-16khz-32kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Audio16Khz128KBitRateMonoMp3]: \"audio-16khz-128kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Audio16Khz64KBitRateMonoMp3]: \"audio-16khz-64kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3]: \"audio-24khz-48kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Audio24Khz96KBitRateMonoMp3]: \"audio-24khz-96kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Audio24Khz160KBitRateMonoMp3]: \"audio-24khz-160kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Raw16Khz16BitMonoTrueSilk]: \"raw-16khz-16bit-mono-truesilk\",\n [SpeechSynthesisOutputFormat.Riff16Khz16BitMonoPcm]: \"riff-16khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Riff8Khz16BitMonoPcm]: \"riff-8khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Riff24Khz16BitMonoPcm]: \"riff-24khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Riff8Khz8BitMonoMULaw]: \"riff-8khz-8bit-mono-mulaw\",\n [SpeechSynthesisOutputFormat.Raw16Khz16BitMonoPcm]: \"raw-16khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Raw24Khz16BitMonoPcm]: \"raw-24khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Raw8Khz16BitMonoPcm]: \"raw-8khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Ogg16Khz16BitMonoOpus]: \"ogg-16khz-16bit-mono-opus\",\n [SpeechSynthesisOutputFormat.Ogg24Khz16BitMonoOpus]: \"ogg-24khz-16bit-mono-opus\",\n [SpeechSynthesisOutputFormat.Raw48Khz16BitMonoPcm]: \"raw-48khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Riff48Khz16BitMonoPcm]: \"riff-48khz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Audio48Khz96KBitRateMonoMp3]: \"audio-48khz-96kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Audio48Khz192KBitRateMonoMp3]: \"audio-48khz-192kbitrate-mono-mp3\",\n [SpeechSynthesisOutputFormat.Ogg48Khz16BitMonoOpus]: \"ogg-48khz-16bit-mono-opus\",\n [SpeechSynthesisOutputFormat.Webm16Khz16BitMonoOpus]: \"webm-16khz-16bit-mono-opus\",\n [SpeechSynthesisOutputFormat.Webm24Khz16BitMonoOpus]: \"webm-24khz-16bit-mono-opus\",\n [SpeechSynthesisOutputFormat.Webm24Khz16Bit24KbpsMonoOpus]: \"webm-24khz-16bit-24kbps-mono-opus\",\n [SpeechSynthesisOutputFormat.Raw24Khz16BitMonoTrueSilk]: \"raw-24khz-16bit-mono-truesilk\",\n [SpeechSynthesisOutputFormat.Raw8Khz8BitMonoALaw]: \"raw-8khz-8bit-mono-alaw\",\n [SpeechSynthesisOutputFormat.Riff8Khz8BitMonoALaw]: \"riff-8khz-8bit-mono-alaw\",\n [SpeechSynthesisOutputFormat.Audio16Khz16Bit32KbpsMonoOpus]: \"audio-16khz-16bit-32kbps-mono-opus\",\n [SpeechSynthesisOutputFormat.Audio24Khz16Bit48KbpsMonoOpus]: \"audio-24khz-16bit-48kbps-mono-opus\",\n [SpeechSynthesisOutputFormat.Audio24Khz16Bit24KbpsMonoOpus]: \"audio-24khz-16bit-24kbps-mono-opus\",\n [SpeechSynthesisOutputFormat.Raw22050Hz16BitMonoPcm]: \"raw-22050hz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Riff22050Hz16BitMonoPcm]: \"riff-22050hz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Raw44100Hz16BitMonoPcm]: \"raw-44100hz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.Riff44100Hz16BitMonoPcm]: \"riff-44100hz-16bit-mono-pcm\",\n [SpeechSynthesisOutputFormat.AmrWb16000Hz]: \"amr-wb-16000hz\",\n [SpeechSynthesisOutputFormat.G72216Khz64Kbps]: \"g722-16khz-64kbps\",\n };\n private priAudioFormatString: string;\n /**\n * audio format string for synthesis request, which may differ from priAudioFormatString.\n * e.g. for riff format, we will request raw format and add a header in SDK side.\n */\n private readonly priRequestAudioFormatString: string;\n private readonly priHasHeader: boolean;\n\n /**\n * Creates an instance with the given values.\n * @constructor\n * @param formatTag\n * @param {number} channels - Number of channels.\n * @param {number} samplesPerSec - Samples per second.\n * @param {number} avgBytesPerSec - Average bytes per second.\n * @param {number} blockAlign - Block alignment.\n * @param {number} bitsPerSample - Bits per sample.\n * @param {string} audioFormatString - Audio format string\n * @param {string} requestAudioFormatString - Audio format string sent to service.\n * @param {boolean} hasHeader - If the format has header or not.\n */\n public constructor(formatTag: AudioFormatTag,\n channels: number,\n samplesPerSec: number,\n avgBytesPerSec: number,\n blockAlign: number,\n bitsPerSample: number,\n audioFormatString: string,\n requestAudioFormatString: string,\n hasHeader: boolean) {\n super(samplesPerSec, bitsPerSample, channels, formatTag);\n this.formatTag = formatTag;\n this.avgBytesPerSec = avgBytesPerSec;\n this.blockAlign = blockAlign;\n this.priAudioFormatString = audioFormatString;\n this.priRequestAudioFormatString = requestAudioFormatString;\n this.priHasHeader = hasHeader;\n }\n\n public static fromSpeechSynthesisOutputFormat(speechSynthesisOutputFormat?: SpeechSynthesisOutputFormat): AudioOutputFormatImpl {\n if (speechSynthesisOutputFormat === undefined) {\n return AudioOutputFormatImpl.getDefaultOutputFormat();\n }\n return AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(\n AudioOutputFormatImpl.SpeechSynthesisOutputFormatToString[speechSynthesisOutputFormat]);\n }\n\n public static fromSpeechSynthesisOutputFormatString(speechSynthesisOutputFormatString: string): AudioOutputFormatImpl {\n switch (speechSynthesisOutputFormatString) {\n case \"raw-8khz-8bit-mono-mulaw\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MuLaw,\n 1,\n 8000,\n 8000,\n 1,\n 8,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"riff-16khz-16kbps-mono-siren\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.Siren,\n 1,\n 16000,\n 2000,\n 40,\n 0,\n speechSynthesisOutputFormatString,\n \"audio-16khz-16kbps-mono-siren\",\n true);\n case \"audio-16khz-16kbps-mono-siren\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.Siren,\n 1,\n 16000,\n 2000,\n 40,\n 0,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-16khz-32kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 16000,\n 32 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-16khz-128kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 16000,\n 128 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-16khz-64kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 16000,\n 64 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-24khz-48kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 24000,\n 48 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-24khz-96kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 24000,\n 96 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-24khz-160kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 24000,\n 160 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"raw-16khz-16bit-mono-truesilk\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.SILKSkype,\n 1,\n 16000,\n 32000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n\n case \"riff-8khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 8000,\n 16000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-8khz-16bit-mono-pcm\",\n true);\n case \"riff-24khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 24000,\n 48000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-24khz-16bit-mono-pcm\",\n true);\n case \"riff-8khz-8bit-mono-mulaw\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MuLaw,\n 1,\n 8000,\n 8000,\n 1,\n 8,\n speechSynthesisOutputFormatString,\n \"raw-8khz-8bit-mono-mulaw\",\n true);\n case \"raw-16khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 16000,\n 32000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-16khz-16bit-mono-pcm\",\n false);\n case \"raw-24khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 24000,\n 48000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-24khz-16bit-mono-pcm\",\n false);\n case \"raw-8khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 8000,\n 16000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-8khz-16bit-mono-pcm\",\n false);\n case \"ogg-16khz-16bit-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.OGG_OPUS,\n 1,\n 16000,\n 8192,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"ogg-24khz-16bit-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.OGG_OPUS,\n 1,\n 24000,\n 8192,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"raw-48khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 48000,\n 96000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-48khz-16bit-mono-pcm\",\n false);\n case \"riff-48khz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 48000,\n 96000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-48khz-16bit-mono-pcm\",\n true);\n case \"audio-48khz-96kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 48000,\n 96 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-48khz-192kbitrate-mono-mp3\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.MP3,\n 1,\n 48000,\n 192 << 7,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"ogg-48khz-16bit-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.OGG_OPUS,\n 1,\n 48000,\n 12000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"webm-16khz-16bit-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.WEBM_OPUS,\n 1,\n 16000,\n 4000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"webm-24khz-16bit-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.WEBM_OPUS,\n 1,\n 24000,\n 6000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"webm-24khz-16bit-24kbps-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.WEBM_OPUS,\n 1,\n 24000,\n 3000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-16khz-16bit-32kbps-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.OPUS,\n 1,\n 16000,\n 4000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-24khz-16bit-48kbps-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.OPUS,\n 1,\n 24000,\n 6000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-24khz-16bit-24kbps-mono-opus\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.OPUS,\n 1,\n 24000,\n 3000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-24khz-16bit-mono-flac\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.FLAC,\n 1,\n 24000,\n 24000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"audio-48khz-16bit-mono-flac\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.FLAC,\n 1,\n 48000,\n 30000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"raw-24khz-16bit-mono-truesilk\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.SILKSkype,\n 1,\n 24000,\n 48000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"raw-8khz-8bit-mono-alaw\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.ALaw,\n 1,\n 8000,\n 8000,\n 1,\n 8,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"riff-8khz-8bit-mono-alaw\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.ALaw,\n 1,\n 8000,\n 8000,\n 1,\n 8,\n speechSynthesisOutputFormatString,\n \"raw-8khz-8bit-mono-alaw\",\n true);\n case \"raw-22050hz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 22050,\n 44100,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"riff-22050hz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 22050,\n 44100,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-22050hz-16bit-mono-pcm\",\n true);\n case \"raw-44100hz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 44100,\n 88200,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"riff-44100hz-16bit-mono-pcm\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 44100,\n 88200,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n \"raw-44100hz-16bit-mono-pcm\",\n true);\n case \"amr-wb-16000h\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.AMR_WB,\n 1,\n 16000,\n 3052,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"g722-16khz-64kbps\":\n return new AudioOutputFormatImpl(\n AudioFormatTag.G722,\n 1,\n 16000,\n 8000,\n 2,\n 16,\n speechSynthesisOutputFormatString,\n speechSynthesisOutputFormatString,\n false);\n case \"riff-16khz-16bit-mono-pcm\":\n default:\n return new AudioOutputFormatImpl(\n AudioFormatTag.PCM,\n 1,\n 16000,\n 32000,\n 2,\n 16,\n \"riff-16khz-16bit-mono-pcm\",\n \"raw-16khz-16bit-mono-pcm\",\n true);\n }\n }\n\n public static getDefaultOutputFormat(): AudioOutputFormatImpl {\n return AudioOutputFormatImpl.fromSpeechSynthesisOutputFormatString(\n (typeof window !== \"undefined\") ? \"audio-24khz-48kbitrate-mono-mp3\" : \"riff-16khz-16bit-mono-pcm\");\n }\n\n /**\n * The format tag of the audio\n * @AudioFormatTag AudioOutputFormatImpl.prototype.formatTag\n * @function\n * @public\n */\n public formatTag: AudioFormatTag;\n\n /**\n * Specifies if this audio output format has a header\n * @boolean AudioOutputFormatImpl.prototype.hasHeader\n * @function\n * @public\n */\n public get hasHeader(): boolean {\n return this.priHasHeader;\n }\n\n /**\n * Specifies the header of this format\n * @ArrayBuffer AudioOutputFormatImpl.prototype.header\n * @function\n * @public\n */\n public get header(): ArrayBuffer {\n if (this.hasHeader) {\n return this.privHeader;\n }\n return undefined;\n }\n\n /**\n * Updates the header based on the audio length\n * @member AudioOutputFormatImpl.updateHeader\n * @function\n * @public\n * @param {number} audioLength - the audio length\n */\n public updateHeader(audioLength: number): void {\n if (this.priHasHeader) {\n const view = new DataView(this.privHeader);\n view.setUint32(4, audioLength + this.privHeader.byteLength - 8, true);\n view.setUint32(40, audioLength, true);\n }\n }\n\n /**\n * Specifies the audio format string to be sent to the service\n * @string AudioOutputFormatImpl.prototype.requestAudioFormatString\n * @function\n * @public\n */\n public get requestAudioFormatString(): string {\n return this.priRequestAudioFormatString;\n }\n\n /**\n * Adds audio header\n * @param audio the raw audio without header\n * @returns the audio with header if applicable\n */\n\n public addHeader(audio: ArrayBuffer): ArrayBuffer {\n if (!this.hasHeader) {\n return audio;\n }\n this.updateHeader(audio.byteLength);\n const tmp = new Uint8Array(audio.byteLength + this.header.byteLength);\n tmp.set(new Uint8Array(this.header), 0);\n tmp.set(new Uint8Array(audio), this.header.byteLength);\n return tmp.buffer;\n }\n\n}\n"]}