Files
adaptive-music/scripts/check_synthetic_pipeline.mjs
T

12 lines
1.0 KiB
JavaScript
Raw Normal View History

2026-12-03 16:11:47 -05:00
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));