"""Freeze one static parent's room and longer, aligned real-speech excerpts. Author-side preparation. Public reproduction starts at the bundled recipe and source FLACs and does not require the author's static manifests or local paths. """ from __future__ import annotations import argparse import copy import gzip import json import shutil from pathlib import Path import numpy as np import soundfile as sf from .common import SR, VERSION, position, sha, speech_activity, uid, write from .motion import SHIFTS, revised_recipe def rows(path): with gzip.open(path, 'rt') as f: for line in f: yield json.loads(line) def prepare(release, corpus, out): parent_id = 'b44440882fb683045c9bafb5' parent = next(r for r in rows(release/'unified_test.jsonl.gz') if r['scene_id']==parent_id) room = next(r for r in rows(release/'rooms.jsonl.gz') if r['room_id']==parent['room_id'] and r['split']=='test') out.mkdir(parents=True, exist_ok=True) assets = out/'assets/room' assets.mkdir(parents=True, exist_ok=True) from generation.native.build_static_v1_scene import build_glb surfaces = [(s['name'], s['class_'], s['location'], s['size']) for s in room['layout']['surfaces']] build_glb(assets/'geometry.glb', surfaces, room['room_id']) shutil.copyfile(assets/'geometry.glb', assets/'geometry.semantic.glb') for name, value in room['files'].items(): (assets/name).write_text(value) for name, h in room['asset_hashes'].items(): if sha(assets/name)!=h: raise ValueError('Room asset failed pinned checksum: '+name) write(assets/'layout.json', room['layout']) materials = {m['scene_source_id']:m for m in parent['materials']} alignments = {} hashes = {m['sha256'] for m in materials.values()} for row in rows(release/'alignment_crops.jsonl.gz'): c = row['crop'] if c['source_sha256'] in hashes: alignments.setdefault(c['source_sha256'], c['words']) source_dir = out/'assets/sources' source_dir.mkdir(parents=True, exist_ok=True) specs = {'H01':[(1,8,.35),(8,13,4.5)], 'H02':[(0,11,1.5),(11,16,5.1)], 'R02':[(3,7,3.1)]} physical = {s['source_id']:s for s in parent['physical_scene']['sources']} entities = [] for sid in ('H01','H02','R02'): m = materials[sid] source_path = corpus/'extracted'/m['corpus_path'] if sha(source_path)!=m['sha256']: raise ValueError('Original source mismatch') target = source_dir/(sid+'.flac') shutil.copyfile(source_path, target) wave, sr = sf.read(target, dtype='float32') if sr!=SR or wave.ndim!=1: raise ValueError('Expected original 16 kHz mono speech') events=[] for index,(first,last,time_s) in enumerate(specs[sid]): ws=alignments[m['sha256']][first:last] a=max(0,round((ws[0]['start_s']-.03)*SR)) b=min(len(wave),round((ws[-1]['end_s']+.04)*SR)) start=round(time_s*SR) events.append(dict(event_id=uid('event',sid,index), source_id=sid, audio_asset='assets/sources/'+sid+'.flac', original_source_sha256=m['sha256'], original_corpus_path=m['corpus_path'], crop_samples=[a,b], start_sample=start, end_sample=start+b-a, text=' '.join(w['word'] for w in ws), activity_samples=speech_activity(wave[a:b],start), words=[dict(word=w['word'], start_sample=start+round(w['start_s']*SR)-a, end_sample=start+round(w['end_s']*SR)-a, alignment_score=w['mean_score']) for w in ws])) entities.append(dict(entity_id=sid, entity_type=m['role'], speaker_id=m['speaker_id'], initial_xyz_m=physical[sid]['position_m'], yaw_deg=0., displacement_m=[0.,0.,0.], motion_duration_s=6.3, emitted_rms_dbfs=-22. if sid!='R02' else -25., events=events)) robots=[] for r in parent['physical_scene']['robot_poses']: robots.append(dict(entity_id=r['robot_id'],entity_type='robot',initial_xyz_m=r['microphone_position_m'], yaw_deg=r['yaw_deg'],displacement_m=[0.,0.,0.],motion_duration_s=6.3, playback_role='silent' if r['robot_id']=='R01' else 'playback', coincident_microphone_and_loudspeaker_centers=True)) shifts=SHIFTS scenes=[] for branch,moving in [('easy_human',['H01']),('easy_robot',['R01']),('hard_joint',list(shifts))]: s=dict(schema_version=VERSION,scene_id=uid(parent_id,branch),parent_static_scene_id=parent_id, scene_group_id=uid(parent_id,'paired_motion'),branch=branch, difficulty='hard' if branch=='hard_joint' else 'easy',room_id=room['room_id'], duration_samples=parent['frames'],sample_rate_hz=SR,evaluation_step_samples=1600, moving_entity_ids=moving,humans=copy.deepcopy(entities[:2]),robots=copy.deepcopy(robots), playback_sources=copy.deepcopy(entities[2:]),strict_sync=True, own_playback_policy='ideal_own_only',coordinate_convention=dict(world_up='+Y', azimuth_positive='left',yaw_zero='world -Z',yaw_positive='toward world +X')) for e in s['humans']+s['robots']: if e['entity_id'] in moving: e['displacement_m']=shifts[e['entity_id']] for e in s['playback_sources']: r=next(r for r in s['robots'] if r['entity_id']==e['entity_id']) e['displacement_m']=r['displacement_m'];e['yaw_deg']=r['yaw_deg'] scenes.append(s) settings=copy.deepcopy(parent['renderer']);settings['threadCount']=2 recipe=dict(schema_version=VERSION,seed=20261001,parent_static_scene_id=parent_id, parent_static_duration_samples=parent['frames'],parent_release_sha256=sha(release/'release.json'), speech_style='aligned real LibriSpeech excerpts; assembled turns, not natural conversation', source_license='CC BY 4.0',room=room['layout'],room_assets_sha256=room['asset_hashes'], foa_mapping=room['mapping'],renderer=settings,source_node_step_s=.2,receiver_node_step_s=.3, rendering_method='two-time source-emission / receiver-reception RIR basis interpolation; quasi-static propagation', motion_model='minimum-jerk horizontal translation; fixed height and yaw',scenes=scenes) write(out/'data/recipe.json',revised_recipe(recipe)) # The checked-in long-utterance alignment selects the current diagnostic demo. if (out/'assets/sources/H01_alignment.json').exists(): selection=json.loads((out/'assets/sources/H01_alignment.json').read_text()) shutil.copyfile(corpus/'extracted'/selection['original_corpus_path'],out/'assets/sources/H01.flac') from .continuous import prepare as continuous_prepare continuous_prepare(out) print('Prepared',len(scenes),'scenes; duration',parent['frames']/SR,'s',flush=True) if __name__=='__main__': p=argparse.ArgumentParser();p.add_argument('--release',type=Path,required=True) p.add_argument('--corpus',type=Path,required=True);p.add_argument('--out',type=Path,required=True) a=p.parse_args();prepare(a.release,a.corpus,a.out)