UNPKG

echogarden

Version:

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

15 lines 708 B
import { decodeToChannels } from '../audio/AudioBufferConversion.js'; import { decodeAscii } from '../encodings/Ascii.js'; import { readFileAsBinary } from '../utilities/FileSystem.js'; import { SampleFormat } from './WaveCodec.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