UNPKG

echogarden

Version:

An easy-to-use speech toolset. Includes tools for synthesis, recognition, alignment, speech translation, language detection, source separation and more.

14 lines 675 B
import { decodeToChannels, SampleFormat } from '../audio/AudioBufferConversion.js'; import { decodeAscii } from '../encodings/Ascii.js'; import { readFileAsBinary } from '../utilities/FileSystem.js'; export async function decodeTimitAudioFile(filename) { return decodeTimitAudio(await readFileAsBinary(filename)); } export function decodeTimitAudio(data) { if (decodeAscii(data.subarray(0, 16)) != 'NIST_1A\n 1024\n') { throw new Error('Data is not a valid TIMIT audio file'); } const pcm = data.subarray(1024); return { audioChannels: decodeToChannels(pcm, 1, 16, SampleFormat.PCM), sampleRate: 16000 }; } //# sourceMappingURL=TIMITCodec.js.map