13 lines
1.0 KiB
JavaScript
13 lines
1.0 KiB
JavaScript
import {readFile,writeFile} from 'node:fs/promises';
|
|
import {createHash} from 'node:crypto';
|
|
import {pcmFixtureFrames} from '../gateway/pcm-fixture.mjs';
|
|
const manifest=JSON.parse(await readFile('.local/synthetic-audio/manifest.json','utf8'));
|
|
const result={checked_at:new Date().toISOString(),evidence_class:'local generated audio decoding',tracks:0,frames:0,duration_seconds:0,hashes_match:true};
|
|
for(const tracks of Object.values(manifest.sequences))for(const track of tracks){
|
|
const bytes=await readFile(`.local/synthetic-audio/${track.file}`);
|
|
if(createHash('sha256').update(bytes).digest('hex')!==track.sha256)throw Error('fixture mismatch');
|
|
let frames=0;for(const frame of pcmFixtureFrames(bytes)){if(frame.length!==1920)throw Error('frame mismatch');frames++;}
|
|
if(frames!==4500)throw Error('duration mismatch');result.tracks++;result.frames+=frames;result.duration_seconds+=frames*.02;
|
|
}
|
|
await writeFile('evidence/synthetic-pipeline.json',JSON.stringify(result,null,2)+'\n');console.log(JSON.stringify(result));
|