Datasets:
File size: 2,426 Bytes
347d9a3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | """Initialize accepted dynamic recipes from GitHub + checksum-pinned official speech."""
from __future__ import annotations
import argparse,shutil
from pathlib import Path
from .common import read,rows,jsonl,sha,write
from .prepare import freeze_room
from generation.sources import prepare as official_sources
def bootstrap(release,corpus,root):
release=release.resolve();root=root.resolve();corpus=corpus.resolve()
groups=list(rows(release/'recipes.jsonl.gz'));config=read(release/'config.json')
if (root/'config.json').exists() and read(root/'config.json')!=config:raise ValueError('Existing output configuration differs')
materials={}
for group in groups:
for source in group['scenes'][0]['humans']+group['scenes'][0]['playback_sources']:
for event in source['events']:
rel=event['original_corpus_path'];digest=event['original_source_sha256']
if rel in materials and materials[rel]['sha256']!=digest:raise ValueError('Contradictory original source')
materials[rel]=dict(corpus_path=rel,sha256=digest)
official_sources([dict(materials=list(materials.values()))],corpus)
for group in groups:
for source in group['scenes'][0]['humans']+group['scenes'][0]['playback_sources']:
for event in source['events']:
original=corpus/'extracted'/event['original_corpus_path'];target=root/event['audio_asset'];target.parent.mkdir(parents=True,exist_ok=True)
if target.exists():
if sha(target)!=event['original_source_sha256']:raise ValueError('Changed original at output')
else:shutil.copyfile(original,target)
repo=Path(__file__).resolve().parent.parent;rooms={r['room_id']:r for r in rows(repo/'generation/releases/20260930/rooms.jsonl.gz')}
for room_id in sorted({g['room_id'] for g in groups}):freeze_room(root/'public/assets/rooms'/room_id,rooms[room_id])
write(root/'config.json',config);jsonl(root/'private/recipes.jsonl',groups)
print('INITIALIZED',len(groups)*4,'scenes',len(materials),'original speech files',flush=True)
if __name__=='__main__':
p=argparse.ArgumentParser();p.add_argument('--release',type=Path,default=Path(__file__).parent/'releases/20261001')
p.add_argument('--corpus',type=Path,required=True);p.add_argument('--root',type=Path,required=True);a=p.parse_args();bootstrap(a.release,a.corpus,a.root)
|