Heiheihaha17 commited on
Commit
2e20433
·
verified ·
1 Parent(s): 347d9a3

Add files using upload-large-folder tool

Browse files
Files changed (50) hide show
  1. code/dynamic_demo/Dockerfile +31 -0
  2. code/dynamic_demo/__init__.py +1 -0
  3. code/dynamic_demo/prepare.py +128 -0
  4. code/dynamic_demo/render.py +276 -0
  5. code/dynamic_demo/validate.py +221 -0
  6. static/public/audio/test/5cd6ca88b6a6354719190189/R01_foa.wav +3 -0
  7. static/public/audio/test/5cd6ca88b6a6354719190189/R02_foa.wav +3 -0
  8. static/public/audio/test/6227c8e456fc5c2abe229d39/R01_foa.wav +3 -0
  9. static/public/audio/test/6227c8e456fc5c2abe229d39/R02_foa.wav +3 -0
  10. static/public/audio/test/62813725c676711765a9f517/R01_foa.wav +3 -0
  11. static/public/audio/test/62813725c676711765a9f517/R02_foa.wav +3 -0
  12. static/public/audio/test/70f37d9dc9eea6570196c752/R01_foa.wav +3 -0
  13. static/public/audio/test/714ac7cf5d22ca4503e8d335/R01_foa.wav +3 -0
  14. static/public/audio/test/714ac7cf5d22ca4503e8d335/R02_foa.wav +3 -0
  15. static/public/audio/test/7681c220a49f3aa111b8c969/R01_foa.wav +3 -0
  16. static/public/audio/test/7681c220a49f3aa111b8c969/R02_foa.wav +3 -0
  17. static/public/audio/test/78012807030176bafef23d13/R01_foa.wav +3 -0
  18. static/public/audio/test/78012807030176bafef23d13/R02_foa.wav +3 -0
  19. static/public/audio/test/7ab4ebddd1dcc83f4ee351bb/R01_foa.wav +3 -0
  20. static/public/audio/test/7ab4ebddd1dcc83f4ee351bb/R02_foa.wav +3 -0
  21. static/public/audio/test/7ab4ebddd1dcc83f4ee351bb/R03_foa.wav +3 -0
  22. static/public/audio/test/832b6dafe593bb3f8fe44ddf/R01_foa.wav +3 -0
  23. static/public/audio/test/832b6dafe593bb3f8fe44ddf/R02_foa.wav +3 -0
  24. static/public/audio/test/832b6dafe593bb3f8fe44ddf/R03_foa.wav +3 -0
  25. static/public/audio/test/8571c3158d8e3dd34ce02110/R01_foa.wav +3 -0
  26. static/public/audio/test/8571c3158d8e3dd34ce02110/R02_foa.wav +3 -0
  27. static/public/audio/test/898f528190a6b19ece5a345b/R01_foa.wav +3 -0
  28. static/public/audio/test/89c5e37d3786814006a7deed/R01_foa.wav +3 -0
  29. static/public/audio/test/89c5e37d3786814006a7deed/R02_foa.wav +3 -0
  30. static/public/audio/test/89c5e37d3786814006a7deed/R03_foa.wav +3 -0
  31. static/public/audio/test/8c79bf31e6237444d57c18d1/R01_foa.wav +3 -0
  32. static/public/audio/test/8c79bf31e6237444d57c18d1/R02_foa.wav +3 -0
  33. static/public/audio/test/8c79bf31e6237444d57c18d1/R03_foa.wav +3 -0
  34. static/public/audio/test/8f0b5e1379fe7d41646ac92a/R01_foa.wav +3 -0
  35. static/public/audio/test/8f0b5e1379fe7d41646ac92a/R02_foa.wav +3 -0
  36. static/public/audio/test/8f0b5e1379fe7d41646ac92a/R03_foa.wav +3 -0
  37. static/public/audio/test/999f3f6f30909bb0602f6035/R01_foa.wav +3 -0
  38. static/public/audio/test/999f3f6f30909bb0602f6035/R02_foa.wav +3 -0
  39. static/public/audio/test/999f3f6f30909bb0602f6035/R03_foa.wav +3 -0
  40. static/public/audio/test/a267981e8d98836e34903fc5/R01_foa.wav +3 -0
  41. static/public/audio/test/a267981e8d98836e34903fc5/R02_foa.wav +3 -0
  42. static/public/audio/test/adb3360aee801d97a7d5e658/R01_foa.wav +3 -0
  43. static/public/audio/test/adb3360aee801d97a7d5e658/R02_foa.wav +3 -0
  44. static/public/audio/test/adb3360aee801d97a7d5e658/R03_foa.wav +3 -0
  45. static/public/audio/test/afedaa58abcadd37e4890c79/R01_foa.wav +3 -0
  46. static/public/audio/test/b0560b662f87894178727d48/R01_foa.wav +3 -0
  47. static/public/audio/test/b0ce3c80e4ae4abeffbadb3c/R01_foa.wav +3 -0
  48. static/public/audio/test/b8627dee6b2252c9d0c83ba7/R01_foa.wav +3 -0
  49. static/public/audio/test/b9af50c644960c3036f5f20c/R02_foa.wav +3 -0
  50. static/public/audio/test/bb6b7bc842c335944e50f300/R02_foa.wav +3 -0
code/dynamic_demo/Dockerfile ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build context is the repository root or the extracted reproduction bundle root.
2
+ FROM ubuntu:24.04
3
+ ENV DEBIAN_FRONTEND=noninteractive
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ python3 python3-dev python3-venv git git-lfs build-essential cmake ninja-build \
6
+ libegl1-mesa-dev libgl1-mesa-dev libopengl-dev libgl1-mesa-dri libsndfile1 \
7
+ ca-certificates curl && rm -rf /var/lib/apt/lists/*
8
+ RUN python3 -m venv /opt/venv
9
+ ENV PATH=/opt/venv/bin:$PATH
10
+ COPY dynamic_demo/requirements.txt /tmp/requirements.txt
11
+ RUN pip install --no-cache-dir -r /tmp/requirements.txt
12
+ COPY generation/native/source_xyz.patch /tmp/source_xyz.patch
13
+ ARG HABITAT_COMMIT=57ee4941dc4765240f0f91f70b2c97a919bf9038
14
+ ARG RLR_COMMIT=4fd446b4abb5c71fb7a232a083bbddd65f25fc6f
15
+ RUN git init /opt/habitat-sim && cd /opt/habitat-sim && \
16
+ git remote add origin https://github.com/facebookresearch/habitat-sim.git && \
17
+ git fetch --depth=1 origin "$HABITAT_COMMIT" && git checkout --detach FETCH_HEAD && \
18
+ git submodule update --init --recursive --depth=1 \
19
+ src/deps/assimp src/deps/corrade src/deps/magnum src/deps/magnum-bindings \
20
+ src/deps/magnum-integration src/deps/magnum-plugins src/deps/openexr \
21
+ src/deps/pybind11 src/deps/rapidjson src/deps/recastnavigation \
22
+ src/deps/rlr-audio-propagation src/deps/tinyobjloader src/deps/zstd && \
23
+ test "$(git -C src/deps/rlr-audio-propagation rev-parse HEAD)" = "$RLR_COMMIT" && \
24
+ git apply --check /tmp/source_xyz.patch && git apply /tmp/source_xyz.patch && \
25
+ CMAKE_BUILD_PARALLEL_LEVEL=4 HABITAT_WITH_AUDIO=ON HABITAT_BUILD_GUI_VIEWERS=OFF \
26
+ HABITAT_WITH_BULLET=OFF HABITAT_WITH_CUDA=OFF pip install --no-deps --no-build-isolation .
27
+ RUN echo "31e948eef4908d8cbb403b5f445d9d0eab59fc81b05a658538f8795984f9bfb4 /opt/habitat-sim/src/deps/rlr-audio-propagation/RLRAudioPropagationPkg/libs/linux/x64/libRLRAudioPropagation.so" | sha256sum --check
28
+ WORKDIR /opt/demo
29
+ COPY . .
30
+ ENV PYTHONUNBUFFERED=1 NUMBA_CACHE_DIR=/tmp/disrobot-numba-cache OMP_NUM_THREADS=2 OPENBLAS_NUM_THREADS=2 MKL_NUM_THREADS=2
31
+ CMD ["python", "-m", "dynamic_demo.render", "--root", "demo/dynamic", "--work", "/tmp/dish-render"]
code/dynamic_demo/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Reproducible, public DiSH dynamic demonstration (not a full benchmark release)."""
code/dynamic_demo/prepare.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Freeze one static parent's room and longer, aligned real-speech excerpts.
2
+
3
+ Author-side preparation. Public reproduction starts at the bundled recipe and
4
+ source FLACs and does not require the author's static manifests or local paths.
5
+ """
6
+ from __future__ import annotations
7
+
8
+ import argparse
9
+ import copy
10
+ import gzip
11
+ import json
12
+ import shutil
13
+ from pathlib import Path
14
+
15
+ import numpy as np
16
+ import soundfile as sf
17
+
18
+ from .common import SR, VERSION, position, sha, speech_activity, uid, write
19
+ from .motion import SHIFTS, revised_recipe
20
+
21
+
22
+ def rows(path):
23
+ with gzip.open(path, 'rt') as f:
24
+ for line in f:
25
+ yield json.loads(line)
26
+
27
+
28
+ def prepare(release, corpus, out):
29
+ parent_id = 'b44440882fb683045c9bafb5'
30
+ parent = next(r for r in rows(release/'unified_test.jsonl.gz') if r['scene_id']==parent_id)
31
+ room = next(r for r in rows(release/'rooms.jsonl.gz') if r['room_id']==parent['room_id'] and r['split']=='test')
32
+ out.mkdir(parents=True, exist_ok=True)
33
+ assets = out/'assets/room'
34
+ assets.mkdir(parents=True, exist_ok=True)
35
+ from generation.native.build_static_v1_scene import build_glb
36
+ surfaces = [(s['name'], s['class_'], s['location'], s['size']) for s in room['layout']['surfaces']]
37
+ build_glb(assets/'geometry.glb', surfaces, room['room_id'])
38
+ shutil.copyfile(assets/'geometry.glb', assets/'geometry.semantic.glb')
39
+ for name, value in room['files'].items():
40
+ (assets/name).write_text(value)
41
+ for name, h in room['asset_hashes'].items():
42
+ if sha(assets/name)!=h:
43
+ raise ValueError('Room asset failed pinned checksum: '+name)
44
+ write(assets/'layout.json', room['layout'])
45
+ materials = {m['scene_source_id']:m for m in parent['materials']}
46
+ alignments = {}
47
+ hashes = {m['sha256'] for m in materials.values()}
48
+ for row in rows(release/'alignment_crops.jsonl.gz'):
49
+ c = row['crop']
50
+ if c['source_sha256'] in hashes:
51
+ alignments.setdefault(c['source_sha256'], c['words'])
52
+ source_dir = out/'assets/sources'
53
+ source_dir.mkdir(parents=True, exist_ok=True)
54
+ specs = {'H01':[(1,8,.35),(8,13,4.5)], 'H02':[(0,11,1.5),(11,16,5.1)], 'R02':[(3,7,3.1)]}
55
+ physical = {s['source_id']:s for s in parent['physical_scene']['sources']}
56
+ entities = []
57
+ for sid in ('H01','H02','R02'):
58
+ m = materials[sid]
59
+ source_path = corpus/'extracted'/m['corpus_path']
60
+ if sha(source_path)!=m['sha256']:
61
+ raise ValueError('Original source mismatch')
62
+ target = source_dir/(sid+'.flac')
63
+ shutil.copyfile(source_path, target)
64
+ wave, sr = sf.read(target, dtype='float32')
65
+ if sr!=SR or wave.ndim!=1:
66
+ raise ValueError('Expected original 16 kHz mono speech')
67
+ events=[]
68
+ for index,(first,last,time_s) in enumerate(specs[sid]):
69
+ ws=alignments[m['sha256']][first:last]
70
+ a=max(0,round((ws[0]['start_s']-.03)*SR))
71
+ b=min(len(wave),round((ws[-1]['end_s']+.04)*SR))
72
+ start=round(time_s*SR)
73
+ events.append(dict(event_id=uid('event',sid,index), source_id=sid,
74
+ audio_asset='assets/sources/'+sid+'.flac', original_source_sha256=m['sha256'],
75
+ original_corpus_path=m['corpus_path'], crop_samples=[a,b], start_sample=start,
76
+ end_sample=start+b-a, text=' '.join(w['word'] for w in ws),
77
+ activity_samples=speech_activity(wave[a:b],start), words=[dict(word=w['word'],
78
+ start_sample=start+round(w['start_s']*SR)-a,
79
+ end_sample=start+round(w['end_s']*SR)-a, alignment_score=w['mean_score']) for w in ws]))
80
+ entities.append(dict(entity_id=sid, entity_type=m['role'], speaker_id=m['speaker_id'],
81
+ initial_xyz_m=physical[sid]['position_m'], yaw_deg=0., displacement_m=[0.,0.,0.],
82
+ motion_duration_s=6.3, emitted_rms_dbfs=-22. if sid!='R02' else -25., events=events))
83
+ robots=[]
84
+ for r in parent['physical_scene']['robot_poses']:
85
+ robots.append(dict(entity_id=r['robot_id'],entity_type='robot',initial_xyz_m=r['microphone_position_m'],
86
+ yaw_deg=r['yaw_deg'],displacement_m=[0.,0.,0.],motion_duration_s=6.3,
87
+ playback_role='silent' if r['robot_id']=='R01' else 'playback',
88
+ coincident_microphone_and_loudspeaker_centers=True))
89
+ shifts=SHIFTS
90
+ scenes=[]
91
+ for branch,moving in [('easy_human',['H01']),('easy_robot',['R01']),('hard_joint',list(shifts))]:
92
+ s=dict(schema_version=VERSION,scene_id=uid(parent_id,branch),parent_static_scene_id=parent_id,
93
+ scene_group_id=uid(parent_id,'paired_motion'),branch=branch,
94
+ difficulty='hard' if branch=='hard_joint' else 'easy',room_id=room['room_id'],
95
+ duration_samples=parent['frames'],sample_rate_hz=SR,evaluation_step_samples=1600,
96
+ moving_entity_ids=moving,humans=copy.deepcopy(entities[:2]),robots=copy.deepcopy(robots),
97
+ playback_sources=copy.deepcopy(entities[2:]),strict_sync=True,
98
+ own_playback_policy='ideal_own_only',coordinate_convention=dict(world_up='+Y',
99
+ azimuth_positive='left',yaw_zero='world -Z',yaw_positive='toward world +X'))
100
+ for e in s['humans']+s['robots']:
101
+ if e['entity_id'] in moving:
102
+ e['displacement_m']=shifts[e['entity_id']]
103
+ for e in s['playback_sources']:
104
+ r=next(r for r in s['robots'] if r['entity_id']==e['entity_id'])
105
+ e['displacement_m']=r['displacement_m'];e['yaw_deg']=r['yaw_deg']
106
+ scenes.append(s)
107
+ settings=copy.deepcopy(parent['renderer']);settings['threadCount']=2
108
+ recipe=dict(schema_version=VERSION,seed=20261001,parent_static_scene_id=parent_id,
109
+ parent_static_duration_samples=parent['frames'],parent_release_sha256=sha(release/'release.json'),
110
+ speech_style='aligned real LibriSpeech excerpts; assembled turns, not natural conversation',
111
+ source_license='CC BY 4.0',room=room['layout'],room_assets_sha256=room['asset_hashes'],
112
+ foa_mapping=room['mapping'],renderer=settings,source_node_step_s=.2,receiver_node_step_s=.3,
113
+ rendering_method='two-time source-emission / receiver-reception RIR basis interpolation; quasi-static propagation',
114
+ motion_model='minimum-jerk horizontal translation; fixed height and yaw',scenes=scenes)
115
+ write(out/'data/recipe.json',revised_recipe(recipe))
116
+ # The checked-in long-utterance alignment selects the current diagnostic demo.
117
+ if (out/'assets/sources/H01_alignment.json').exists():
118
+ selection=json.loads((out/'assets/sources/H01_alignment.json').read_text())
119
+ shutil.copyfile(corpus/'extracted'/selection['original_corpus_path'],out/'assets/sources/H01.flac')
120
+ from .continuous import prepare as continuous_prepare
121
+ continuous_prepare(out)
122
+ print('Prepared',len(scenes),'scenes; duration',parent['frames']/SR,'s',flush=True)
123
+
124
+
125
+ if __name__=='__main__':
126
+ p=argparse.ArgumentParser();p.add_argument('--release',type=Path,required=True)
127
+ p.add_argument('--corpus',type=Path,required=True);p.add_argument('--out',type=Path,required=True)
128
+ a=p.parse_args();prepare(a.release,a.corpus,a.out)
code/dynamic_demo/render.py ADDED
@@ -0,0 +1,276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Two-time RIR interpolation for moving sources AND moving receivers.
2
+
3
+ y[r] = sum_i,j receiver_basis_j(r) * conv(source_basis_i * x, h_ij)[r]
4
+
5
+ h_ij is actually rendered in the same room at source position i and receiver
6
+ position j. Source weights use emission time; receiver weights use reception
7
+ time, including the entire reverberant tail. This is a quasi-static numerical
8
+ approximation, not an exact wave-equation or exact Doppler simulator.
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import math
14
+ import os
15
+ from pathlib import Path
16
+ import socket
17
+ import time
18
+
19
+ import numpy as np
20
+ import soundfile as sf
21
+ from scipy.signal import fftconvolve, resample_poly
22
+
23
+ from .common import SR, position, read, sha, uid, write
24
+
25
+
26
+ def nodes(entity, step):
27
+ if not np.any(entity['displacement_m']):
28
+ return [0.]
29
+ end = entity['motion_duration_s']
30
+ return sorted(set([round(float(t), 9) for t in np.arange(0., end, step)]+[end]))
31
+
32
+
33
+ def basis(knots, i, samples):
34
+ t = np.asarray(samples, dtype=float)/SR
35
+ if len(knots)==1:
36
+ return np.ones_like(t)
37
+ center=knots[i];w=np.ones_like(t)
38
+ if i:
39
+ w=np.where(t<center,(t-knots[i-1])/(center-knots[i-1]),w)
40
+ if i+1<len(knots):
41
+ w=np.where(t>=center,(knots[i+1]-t)/(knots[i+1]-center),w)
42
+ return np.clip(w,0.,1.)
43
+
44
+
45
+ def two_time_convolution(dry, source_nodes, receiver_nodes, kernel, max_tail_s=3.5):
46
+ n=len(dry);out=np.zeros((n,4),np.float64)
47
+ samples=np.arange(n)
48
+ for i,te in enumerate(source_nodes):
49
+ piece=dry*basis(source_nodes,i,samples)
50
+ nz=np.flatnonzero(piece)
51
+ if not len(nz):continue
52
+ lo,hi=int(nz[0]),int(nz[-1])+1
53
+ for j,tr in enumerate(receiver_nodes):
54
+ rw=basis(receiver_nodes,j,samples)
55
+ nzr=np.flatnonzero(rw[lo:min(n,hi+math.ceil(max_tail_s*SR))])
56
+ if not len(nzr):continue
57
+ h=kernel(te,tr)
58
+ if len(h)>math.ceil(max_tail_s*SR):
59
+ raise ValueError('RIR support exceeds declared interpolation horizon')
60
+ y=fftconvolve(piece[lo:hi,None],h,axes=0)
61
+ end=min(n,lo+len(y))
62
+ if end-lo<len(y):
63
+ total=float(np.sum(y*y));tail=float(np.sum(y[end-lo:]**2))
64
+ if tail>max(total,1e-30)*1e-7:
65
+ raise ValueError('Significant output reverberation tail would be truncated')
66
+ out[lo:end]+=y[:end-lo]*rw[lo:end,None]
67
+ return out.astype(np.float32)
68
+
69
+
70
+ def visible(a,b,room):
71
+ a,b=np.asarray(a),np.asarray(b)
72
+ for box in room['surfaces'][6:]:
73
+ low,high=0.,1.;lo=np.asarray(box['location'])-np.asarray(box['size'])/2
74
+ hi=np.asarray(box['location'])+np.asarray(box['size'])/2
75
+ for axis in range(3):
76
+ d=b[axis]-a[axis]
77
+ if abs(d)<1e-12:
78
+ if not lo[axis]<=a[axis]<=hi[axis]:low=2.;break
79
+ else:
80
+ x,z=sorted(((lo[axis]-a[axis])/d,(hi[axis]-a[axis])/d))
81
+ low=max(low,x);high=min(high,z)
82
+ if low<=high and high>1e-4 and low<1-1e-4:return False
83
+ return True
84
+
85
+
86
+ def validate_geometry(recipe):
87
+ room=recipe['room'];width,height,depth=room['room_size_m']
88
+ constraints=recipe.get('motion_constraints',{})
89
+ clearance=constraints.get('wall_and_furniture_clearance_m',.25)
90
+ audit=[]
91
+ for scene in recipe['scenes']:
92
+ entities=scene['humans']+scene['robots'];t=np.arange(0.,scene['duration_samples']/SR,.025)
93
+ minimum=float('inf')
94
+ for e in entities:
95
+ p=position(e,t)
96
+ if not (np.all(np.abs(p[:,0])<width/2-clearance) and np.all(np.abs(p[:,2])<depth/2-clearance)):
97
+ raise ValueError('Trajectory crosses a wall: '+e['entity_id'])
98
+ for box in room['surfaces'][6:]:
99
+ size=np.asarray(box['size'])[[0,2]]/2+clearance
100
+ if np.any(np.all(np.abs(p[:,[0,2]]-np.asarray(box['location'])[[0,2]])<size,axis=1)):
101
+ raise ValueError('Body footprint crosses furniture: '+e['entity_id'])
102
+ speed=1.875*np.linalg.norm(e['displacement_m'])/e['motion_duration_s']
103
+ distance=float(np.linalg.norm(e['displacement_m']))
104
+ if distance and distance<=constraints.get('minimum_moving_displacement_m',0.):
105
+ raise ValueError('Moving entity displacement is too short: '+e['entity_id'])
106
+ if e['motion_duration_s']>scene['duration_samples']/SR:
107
+ raise ValueError('Motion endpoint is outside the recorded clip')
108
+ limit=constraints.get('maximum_human_speed_mps',.8) if e['entity_type']=='human' else constraints.get('maximum_robot_speed_mps',.45)
109
+ if speed>limit:raise ValueError('Trajectory speed above frozen limit')
110
+ for i,e in enumerate(entities):
111
+ for f in entities[i+1:]:
112
+ distance=np.linalg.norm((position(e,t)-position(f,t))[:,[0,2]],axis=1)
113
+ minimum=min(minimum,float(distance.min()))
114
+ if minimum<constraints.get('minimum_entity_clearance_m',.6):raise ValueError('Human/robot collision clearance failed')
115
+ audit.append(dict(scene_id=scene['scene_id'],minimum_horizontal_clearance_m=minimum,
116
+ entity_displacements_m={e['entity_id']:float(np.linalg.norm(e['displacement_m'])) for e in entities},
117
+ maximum_human_speed_mps=max(1.875*np.linalg.norm(e['displacement_m'])/e['motion_duration_s'] for e in scene['humans']),
118
+ maximum_robot_speed_mps=max(1.875*np.linalg.norm(e['displacement_m'])/e['motion_duration_s'] for e in scene['robots'])))
119
+ return audit
120
+
121
+
122
+ class Renderer:
123
+ def __init__(self,root,recipe,cache,position_fn=position):
124
+ # quaternion must precede habitat_sim on this pinned native runtime.
125
+ import quaternion
126
+ import habitat_sim
127
+ self.hs=habitat_sim;self.root=root;self.recipe=recipe;self.cache=cache;self.position=position_fn
128
+ self.cache.mkdir(parents=True,exist_ok=True);self.records={}
129
+ context_path=self.cache/'cache_context.json'
130
+ context=dict(renderer=recipe['renderer'],foa_mapping=recipe['foa_mapping'],
131
+ room_assets_sha256=recipe['room_assets_sha256'])
132
+ if context_path.exists() and read(context_path)!=context:
133
+ raise ValueError('RIR cache belongs to a different renderer, mapping or room')
134
+ write(context_path,context)
135
+ folder=root/'assets/room'
136
+ for name,h in recipe['room_assets_sha256'].items():
137
+ if sha(folder/name)!=h:raise ValueError('Room asset changed: '+name)
138
+ config=habitat_sim.SimulatorConfiguration()
139
+ config.scene_id=str(folder/'stage.stage_config.json')
140
+ config.scene_dataset_config_file=str(folder/'dataset.scene_dataset_config.json')
141
+ config.load_semantic_mesh=True;config.enable_physics=False
142
+ if hasattr(config,'random_seed'):config.random_seed=20260826
143
+ self.sim=habitat_sim.Simulator(habitat_sim.Configuration(config,[habitat_sim.agent.AgentConfiguration()]))
144
+ if not self.sim.semantic_scene:raise ValueError('Acoustic semantic scene was not loaded')
145
+ spec=habitat_sim.AudioSensorSpec();spec.uuid='audio_sensor'
146
+ spec.channelLayout.channelType=habitat_sim.sensor.RLRAudioPropagationChannelLayoutType.Ambisonics
147
+ spec.channelLayout.channelCount=4;spec.position=[0.,0.,0.]
148
+ for k,v in recipe['renderer'].items():
149
+ if hasattr(spec.acousticsConfig,k):setattr(spec.acousticsConfig,k,v)
150
+ self.sim.add_sensor(spec)
151
+ self.sensor=self.sim.get_agent(0)._sensors['audio_sensor']
152
+ self.sensor.setAudioMaterialsJSON(str(folder/'materials.json'))
153
+
154
+ def kernel(self,source,receiver,te,tr):
155
+ a=self.position(source,te);b=self.position(receiver,tr);yaw=receiver['yaw_deg']
156
+ key=uid(self.recipe['room_assets_sha256'],*[round(float(x),7) for x in np.r_[a,b,yaw]])
157
+ path=self.cache/(key+'.npy');meta=self.cache/(key+'.json')
158
+ if path.exists() and meta.exists():
159
+ record=read(meta)
160
+ if sha(path)!=record['sha256']:raise ValueError('Cached RIR hash mismatch')
161
+ self.records[key]=record
162
+ return np.load(path,allow_pickle=False)
163
+ agent=self.sim.get_agent(0);state=agent.get_state()
164
+ state.position=np.asarray(b,np.float32);state.rotation=np.quaternion(1.,0.,0.,0.)
165
+ state.sensor_states={};agent.set_state(state,True)
166
+ self.sensor.setAudioSourceTransform(np.asarray(a,np.float32))
167
+ native=np.asarray(self.sim.get_sensor_observations()['audio_sensor'],np.float32)
168
+ if native.shape[0]!=4:native=native.T
169
+ m=self.recipe['foa_mapping'];w=m['w_polarity']*native[m['w_channel']]
170
+ axes={axis:item['polarity']*native[item['channel']]/math.sqrt(3.) for axis,item in m['world_axis_mapping'].items()}
171
+ q=math.radians(yaw);right=math.cos(q)*axes['world_x']+math.sin(q)*axes['world_z']
172
+ front=math.sin(q)*axes['world_x']-math.cos(q)*axes['world_z']
173
+ h=np.stack([w,-right,axes['world_y'],front])
174
+ energy=np.sum(h.astype(float)**2,axis=0);total=float(energy.sum())
175
+ if not np.isfinite(h).all() or total<=0:raise ValueError('Invalid native RIR')
176
+ first=int(np.flatnonzero(energy>energy.max()*1e-5)[0])
177
+ peak=first+int(np.argmax(energy[first:first+17]))
178
+ v=h[:,peak];actual=np.array([-v[1],v[2],-v[3]])*np.sign(v[0]);actual/=np.linalg.norm(actual)
179
+ d=a-b;local=np.array([math.cos(q)*d[0]+math.sin(q)*d[2],d[1],-math.sin(q)*d[0]+math.cos(q)*d[2]])
180
+ distance=float(np.linalg.norm(d));expected=local/distance
181
+ error=float(np.degrees(np.arccos(np.clip(np.dot(actual,expected),-1,1))))
182
+ los=visible(a,b,self.recipe['room']);delay=peak/32000.
183
+ if los and (error>3. or abs(delay-distance/343.)>.003):
184
+ raise ValueError('Native direct path direction/delay failed: '+str((error,delay,distance)))
185
+ tail=float(energy[-1600:].sum()/total)
186
+ if tail>1e-7:raise ValueError('Native RIR has significant truncated tail')
187
+ # Retain energy to 1e-11, stricter than the output-tail acceptance test.
188
+ remaining=np.cumsum(energy[::-1])[::-1]/total
189
+ end=int(np.flatnonzero(remaining>1e-11)[-1])+1
190
+ h=resample_poly(h[:,:end],1,2,axis=1).T.astype(np.float32)
191
+ np.save(path,h,allow_pickle=False)
192
+ record=dict(rir_id=key,sha256=sha(path),source_xyz_m=a.tolist(),receiver_xyz_m=b.tolist(),
193
+ receiver_yaw_deg=yaw,los=los,direct_angle_error_deg=error,direct_delay_s=delay,
194
+ geometric_delay_s=distance/343.,native_final_50ms_energy_fraction=tail,
195
+ retained_samples=len(h),sample_rate_hz=SR)
196
+ write(meta,record);self.records[key]=record
197
+ print('RIR',len(self.records),key,round(error,3),'deg',flush=True)
198
+ return h
199
+
200
+ def close(self):self.sim.close()
201
+
202
+
203
+ def make_dry(root,scene):
204
+ dry={};gains=[]
205
+ for s in scene['humans']+scene['playback_sources']:
206
+ x=np.zeros(scene['duration_samples'],np.float32)
207
+ for e in s['events']:
208
+ p=root/e['audio_asset']
209
+ if sha(p)!=e['original_source_sha256']:raise ValueError('Source checksum changed')
210
+ full,sr=sf.read(p,dtype='float32');a,b=e['crop_samples'];wave=full[a:b].copy()
211
+ if sr!=SR:raise ValueError('Source sample rate changed')
212
+ fade=min(128,len(wave)//2);wave[:fade]*=np.linspace(0,1,fade);wave[-fade:]*=np.linspace(1,0,fade)
213
+ mask=np.zeros(len(wave),bool)
214
+ for lo,hi in e['activity_samples']:
215
+ mask[max(0,lo-e['start_sample']):min(len(wave),hi-e['start_sample'])]=True
216
+ gain=10**(s['emitted_rms_dbfs']/20)/max(np.sqrt(np.mean(wave[mask].astype(float)**2)),1e-12)
217
+ x[e['start_sample']:e['end_sample']]+=wave*gain
218
+ gains.append(dict(event_id=e['event_id'],dry_gain=float(gain)))
219
+ dry[s['entity_id']]=x
220
+ return dry,gains
221
+
222
+
223
+ def render_all(root,work):
224
+ if 'debug' in socket.gethostname().lower() and not os.environ.get('DISH_ALLOW_LOCAL_RENDER'):
225
+ raise RuntimeError('Use an allocated CPU job here, or explicitly allow a local reproduction machine')
226
+ recipe=read(root/'data/recipe.json');geometry_audit=validate_geometry(recipe)
227
+ engine=Renderer(root,recipe,work/'rirs');mixes={};stems={};gains=None
228
+ start=time.monotonic()
229
+ try:
230
+ for scene in recipe['scenes']:
231
+ dry,gains=make_dry(root,scene)
232
+ for receiver in scene['robots']:
233
+ rid=receiver['entity_id'];key=(scene['branch'],rid)
234
+ signal=np.zeros((scene['duration_samples'],4),np.float64)
235
+ rn=nodes(receiver,recipe['receiver_node_step_s'])
236
+ for source in scene['humans']+scene['playback_sources']:
237
+ sid=source['entity_id']
238
+ if sid==rid:continue
239
+ print('STEM',scene['branch'],rid,sid,flush=True)
240
+ sn=nodes(source,recipe['source_node_step_s'])
241
+ stem=two_time_convolution(dry[sid],sn,rn,lambda te,tr:engine.kernel(source,receiver,te,tr))
242
+ stems[(scene['branch'],rid,sid)]=stem;signal+=stem
243
+ mixes[key]=signal.astype(np.float32)
244
+ peak=max(float(np.max(np.abs(x))) for x in mixes.values());gain=.9/peak
245
+ records=[];stem_records=[];scene_ids={s['branch']:s['scene_id'] for s in recipe['scenes']}
246
+ for (branch,rid),wave in mixes.items():
247
+ folder=root/'audio'/branch;folder.mkdir(parents=True,exist_ok=True)
248
+ wave=(wave*gain).astype(np.float32)
249
+ path=folder/(rid+'_foa.wav');sf.write(path,wave,SR,subtype='FLOAT')
250
+ # Two symmetric virtual cardioid microphones: a stereo audition,
251
+ # not an HRTF/binaural measurement, and never the model input.
252
+ stereo=np.column_stack([.5*wave[:,0]+.5*wave[:,1],.5*wave[:,0]-.5*wave[:,1]])
253
+ preview=folder/(rid+'_preview.wav');sf.write(preview,stereo,SR,subtype='PCM_16')
254
+ records.append(dict(branch=branch,receiver_id=rid,path=str(path.relative_to(root)),
255
+ preview_path=str(preview.relative_to(root)),sha256=sha(path),preview_sha256=sha(preview),
256
+ sample_rate_hz=SR,channels=['W','Y','Z','X'],normalization='SN3D',ordering='ACN',
257
+ samples=len(wave),recording_id=uid(scene_ids[branch],rid,'recording'),global_start_sample=0))
258
+ stemdir=work/'stems';stemdir.mkdir(parents=True,exist_ok=True)
259
+ for (branch,rid,sid),wave in stems.items():
260
+ p=stemdir/(branch+'_'+rid+'_'+sid+'.npy');np.save(p,(wave*gain).astype(np.float32))
261
+ stem_records.append(dict(branch=branch,receiver_id=rid,source_id=sid,path=str(p),sha256=sha(p)))
262
+ result=dict(passed=True,rendering_method=recipe['rendering_method'],
263
+ common_final_gain=gain,original_peak=peak,dry_gains=gains,recordings=records,
264
+ geometry_audit=geometry_audit,rir_records=list(engine.records.values()),
265
+ stem_records=stem_records,wall_seconds=time.monotonic()-start,
266
+ human_listening_audit_completed=False,model_inference_performed=False)
267
+ write(work/'render.complete.json',result)
268
+ public=dict(result);public.pop('stem_records')
269
+ write(root/'data/rendering.json',public)
270
+ print('RENDER COMPLETE',len(records),'recordings',len(engine.records),'RIRs',flush=True)
271
+ finally:engine.close()
272
+
273
+
274
+ if __name__=='__main__':
275
+ p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);p.add_argument('--work',type=Path,required=True)
276
+ a=p.parse_args();render_all(a.root.resolve(),a.work.resolve())
code/dynamic_demo/validate.py ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Validate the public generated bundle and Python/browser scoring parity."""
2
+ from __future__ import annotations
3
+ import argparse
4
+ import copy
5
+ import json
6
+ import math
7
+ import os
8
+ from pathlib import Path
9
+ import subprocess
10
+ import tempfile
11
+
12
+ import numpy as np
13
+ import soundfile as sf
14
+
15
+ from .common import SR, STEP, active, geometry, grid, position, read, sha, tokens, write
16
+ from .render import validate_geometry
17
+ from .score import score
18
+
19
+
20
+ def compare(a,b,path='root'):
21
+ if isinstance(a,dict):
22
+ assert isinstance(b,dict) and set(a)==set(b),(path,a,b)
23
+ for k,v in a.items():compare(v,b[k],path+'.'+k)
24
+ elif isinstance(a,list):
25
+ assert isinstance(b,list) and len(a)==len(b),path
26
+ for i,(v,w) in enumerate(zip(a,b)):compare(v,w,path+str(i))
27
+ elif isinstance(a,(int,float)) and not isinstance(a,bool):
28
+ assert math.isclose(a,b,abs_tol=2e-5,rel_tol=1e-6),(path,a,b)
29
+ else:assert a==b,(path,a,b)
30
+
31
+
32
+ def validate(root,work=None,node=None):
33
+ recipe=read(root/'data/recipe.json');rendering=read(root/'data/rendering.json');demo=read(root/'data/demo.json')
34
+ assert len(demo['scenes'])==3 and len(rendering['recordings'])==6
35
+ assert len({s['duration_samples'] for s in recipe['scenes']})==1
36
+ assert recipe['parent_static_duration_samples']==recipe['scenes'][0]['duration_samples']
37
+ assert not demo['model_inference_performed'] and not rendering['model_inference_performed']
38
+ assert recipe['renderer']['temporalCoherence'] is False
39
+ geometry_audit=validate_geometry(recipe)
40
+ motion_observability=[]
41
+ for scene in recipe['scenes']:
42
+ for human in scene['humans']:
43
+ times=[s/SR for s in grid(scene) if active(human,s)]
44
+ for receiver in scene['robots']:
45
+ azimuths=np.unwrap(np.deg2rad([geometry(human,receiver,t)['doa_deg'][0] for t in times]))
46
+ motion_observability.append(dict(branch=scene['branch'],source_id=human['entity_id'],
47
+ receiver_id=receiver['entity_id'],first_active_time_s=times[0],last_active_time_s=times[-1],
48
+ first_active_doa_deg=geometry(human,receiver,times[0])['doa_deg'],
49
+ last_active_doa_deg=geometry(human,receiver,times[-1])['doa_deg'],
50
+ source_displacement_between_first_last_active_m=float(np.linalg.norm(position(human,times[-1])-position(human,times[0]))),
51
+ active_azimuth_span_deg=float(np.degrees(np.ptp(azimuths)))))
52
+ for name,h in recipe['room_assets_sha256'].items():assert sha(root/'assets/room'/name)==h
53
+ for scene in recipe['scenes']:
54
+ for e in scene['humans']+scene['robots']:
55
+ p=position(e,np.arange(0,scene['duration_samples']/SR,.01));assert np.ptp(p[:,1])==0
56
+ moving=np.linalg.norm(e['displacement_m'])>0
57
+ assert moving==(e['entity_id'] in scene['moving_entity_ids'])
58
+ for human in scene['humans']:
59
+ for evt in human['events']:
60
+ assert sha(root/evt['audio_asset'])==evt['original_source_sha256']
61
+ assert evt['end_sample']-evt['start_sample']==evt['crop_samples'][1]-evt['crop_samples'][0]
62
+ assert all(evt['start_sample']<=a<b<=evt['end_sample'] for a,b in evt['activity_samples'])
63
+ assert evt['text']==' '.join(w['word'] for w in evt['words'])
64
+ assert evt['words'][0]['start_sample']-evt['start_sample']<=SR*.04
65
+ if human['entity_id']=='H01' and recipe.get('continuous_speech_check'):
66
+ assert len(human['events'])==1
67
+ spans=human['events'][0]['activity_samples']
68
+ assert max((y[0]-x[1])/SR for x,y in zip(spans,spans[1:]))<=.35
69
+ assert (spans[-1][1]-spans[0][0])/SR>=6.
70
+ # All branches must retain the same voices, turns and exactly the same duration.
71
+ for h,original in zip(scene['humans'],recipe['scenes'][0]['humans']):
72
+ assert h['speaker_id']==original['speaker_id'] and h['events']==original['events']
73
+ audio=[]
74
+ binaural=rendering.get('binaural_decoding')
75
+ if binaural:
76
+ from .binaural import decoder_filters, decode_foa
77
+ filters,_=decoder_filters(root/binaural['hrtf_asset'])
78
+ for rec in rendering['recordings']:
79
+ assert sha(root/rec['path'])==rec['sha256']
80
+ assert sha(root/rec['preview_path'])==rec['preview_sha256']
81
+ wave,sr=sf.read(root/rec['path'],dtype='float32');preview,psr=sf.read(root/rec['preview_path'],dtype='float32')
82
+ assert sr==psr==SR and wave.shape==(recipe['parent_static_duration_samples'],4) and preview.shape==(len(wave),2)
83
+ assert np.isfinite(wave).all() and 0<float(np.max(np.abs(wave)))<=.90001
84
+ # Audition must decode the exact raw FOA, with PCM quantization only.
85
+ expected=(decode_foa(wave,filters)[0]*binaural['common_audition_gain']) if binaural else np.column_stack([.5*(wave[:,0]+wave[:,1]),.5*(wave[:,0]-wave[:,1])])
86
+ assert float(np.max(np.abs(preview-expected)))<1/32768+1e-7
87
+ for diagnostic in rec.get('diagnostics',{}).values():
88
+ isolated,isr=sf.read(root/diagnostic['path'],dtype='float32')
89
+ audition,asr=sf.read(root/diagnostic['preview_path'],dtype='float32')
90
+ assert isr==asr==SR and isolated.shape==wave.shape and audition.shape==preview.shape
91
+ assert sha(root/diagnostic['path'])==diagnostic['sha256'] and sha(root/diagnostic['preview_path'])==diagnostic['preview_sha256']
92
+ target=decode_foa(isolated,filters)[0]*binaural['common_audition_gain']
93
+ assert float(np.max(np.abs(audition-target)))<1/32768+1e-7
94
+ if work:
95
+ stem=next(s for s in read(work/'render.complete.json')['stem_records'] if s['branch']==rec['branch']
96
+ and s['receiver_id']==rec['receiver_id'] and s['source_id']==diagnostic['diagnostic_source_id'])
97
+ np.testing.assert_array_equal(isolated,np.load(stem['path'],allow_pickle=False))
98
+ if work:
99
+ stems=read(work/'render.complete.json')['stem_records']
100
+ selected=[s for s in stems if s['branch']==rec['branch'] and s['receiver_id']==rec['receiver_id']]
101
+ assert all(s['source_id']!=rec['receiver_id'] for s in selected)
102
+ assert {s['source_id'] for s in selected}==({'H01','H02','R02'}-{rec['receiver_id']})
103
+ reconstructed=sum(np.load(s['path'],allow_pickle=False) for s in selected)
104
+ np.testing.assert_allclose(wave,reconstructed,atol=1e-7)
105
+ tail_start=round(8.5*SR)
106
+ audio.append(dict(branch=rec['branch'],receiver_id=rec['receiver_id'],samples=len(wave),
107
+ peak=float(np.max(np.abs(wave))),rms=float(np.sqrt(np.mean(wave.astype(float)**2))),
108
+ final_0_386s_energy_fraction=float(np.sum(wave[tail_start:].astype(float)**2)/np.sum(wave.astype(float)**2))))
109
+ oracle=[];cases=[];all_samples=[]
110
+ for sd in demo['scenes']:
111
+ scene=sd['scene'];assert len(sd['samples'])==14
112
+ for sample in sd['samples']:
113
+ row,g=sample['input'],sample['gold'];all_samples.append(sample)
114
+ assert row['sample_id']==g['sample_id']
115
+ assert row['time_window_samples']==[0,scene['duration_samples']]
116
+ assert g['expected_times_s']==[x/SR for x in grid(scene)]
117
+ assert row['evaluation_step_samples']==STEP
118
+ assert len(row['receiver_ids'])==len(row['audio_bindings'])==len(row['recording_ids'])
119
+ assert row['setting']==('cloud' if len(row['receiver_ids'])>1 else 'edge')
120
+ assert 'humans' not in row and 'gold' not in row and 'target_source_id' not in row
121
+ assert all(h['speaker_id'] not in row['rendered_prompt'] for h in scene['humans'])
122
+ assert not(row['task_id']=='TEXT_TRAJECTORY' and row['setting']=='edge')
123
+ assert 'delta' not in row['query'] and 'ΔDOA' not in row['rendered_prompt']
124
+ for trace,robot in zip(row['known_robot_poses'],scene['robots']):
125
+ assert trace['yaw_deg']==round(robot['yaw_deg'])
126
+ assert trace['positions']==[[t/SR]+[round(float(x),1) for x in position(robot,t/SR)] for t in grid(scene)]
127
+ output=g['output'];s=score(g,output);assert s['format_valid']
128
+ if row['task_id']=='KW_ASR':
129
+ cue=tokens(row['query']['wake_phrase']);assert 1<=len(cue)<=3
130
+ matched=[h for h in scene['humans'] if any(tokens(e['text'])[:len(cue)]==cue for e in h['events'])]
131
+ assert len(matched)<=1
132
+ expected=' '.join(e['text'] for e in sorted(matched[0]['events'],key=lambda e:e['start_sample'])) if matched else ''
133
+ assert output==expected and s['exact_match']
134
+ else:
135
+ assert s['coverage']==1 and s['mean_error']<1e-5
136
+ if row['task_id']=='DOA_TRAJECTORY':assert {t['track_id'] for t in output['tracks']}=={'H01','H02'}
137
+ else:
138
+ human=next(h for h in scene['humans'] if h['entity_id']==g['target_source_id'])
139
+ receiver=next((r for r in scene['robots'] if r['entity_id']==row['reference_robot_id']),None)
140
+ for f in output['frames']:
141
+ assert f['active']==active(human,round(f['time_s']*SR))
142
+ if f['active']:
143
+ if receiver:assert abs(f['distance_m']-np.linalg.norm(position(human,f['time_s'])-position(receiver,f['time_s'])))<1e-10
144
+ else:np.testing.assert_allclose(f['xyz_m'],position(human,f['time_s']))
145
+ if receiver:
146
+ q=row['query'];t=q['selection_time_s'];lo,hi=q['initial_sector_deg'];az=geometry(human,receiver,t)['doa_deg'][0]
147
+ assert lo+1<az<hi-1,'Ambiguous sector boundary'
148
+ # The one-decimal public receiver pose must still pick the same human.
149
+ rounded=copy.deepcopy(receiver);rounded['initial_xyz_m']=[round(float(x),1) for x in position(receiver,t)];rounded['displacement_m']=[0,0,0];rounded['yaw_deg']=round(receiver['yaw_deg'])
150
+ az=geometry(human,rounded,t)['doa_deg'][0];assert lo+1<az<hi-1
151
+ selected=[h['entity_id'] for h in scene['humans'] if active(h,round(t*SR)) and lo<=geometry(h,receiver,t)['doa_deg'][0]<hi]
152
+ assert selected==[human['entity_id']]
153
+ oracle.append(dict(sample_id=g['sample_id'],output=output))
154
+ predictions=[output,sample['example_prediction'],None]
155
+ if row['task_id']!='KW_ASR':
156
+ partial=copy.deepcopy(output);frame_sets=[t['frames'] for t in partial['tracks']] if row['task_id']=='DOA_TRAJECTORY' else [partial['frames']]
157
+ for fs in frame_sets:del fs[len(fs)//2:]
158
+ predictions.append(partial)
159
+ invalid=copy.deepcopy(output);fs=invalid['tracks'][0]['frames'] if row['task_id']=='DOA_TRAJECTORY' else invalid['frames'];fs.append(copy.deepcopy(fs[0]));predictions.append(invalid)
160
+ for prediction in predictions:cases.append(dict(gold=g,prediction=prediction))
161
+ assert len(all_samples)==42 and len({s['input']['sample_id'] for s in all_samples})==42
162
+ pairs=[json.loads(x) for x in (root/'data/pairs.jsonl').read_text().splitlines()]
163
+ assert len(pairs)==18
164
+ byid={s['input']['sample_id']:s for s in all_samples}
165
+ for pair in pairs:
166
+ samples=[byid[v['sample_id']] for v in pair['samples']]
167
+ assert len({s['input']['scene_id'] for s in samples})==1
168
+ assert len({s['gold']['target_source_id'] for s in samples})==1
169
+ if pair['task_id']=='KW_ASR':assert len(samples)==3 and len({s['gold']['output'] for s in samples})==1
170
+ elif pair['task_id'] in ('DOA_TRAJECTORY','RANGE_TRAJECTORY'):
171
+ assert len(samples)==2 and samples[0]['gold']['output']!=samples[1]['gold']['output']
172
+ else:assert len(samples)==1
173
+ los=[r for r in rendering['rir_records'] if r['los']]
174
+ assert los and max(r['direct_angle_error_deg'] for r in los)<3
175
+ assert max(r['native_final_50ms_energy_fraction'] for r in rendering['rir_records'])<1e-7
176
+ parity=None
177
+ if node:
178
+ with tempfile.TemporaryDirectory() as temp:
179
+ p=Path(temp)/'cases.json';write(p,cases)
180
+ result=subprocess.run([node,str(Path(__file__).parent/'tests/parity.mjs'),str(p)],capture_output=True,text=True,check=True)
181
+ browser=json.loads(result.stdout);assert len(browser)==len(cases)
182
+ for c,js in zip(cases,browser):compare(score(c['gold'],c['prediction']),js)
183
+ parity=dict(passed=True,cases=len(cases),numeric_tolerance=2e-5)
184
+ report=dict(passed=True,scene_count=3,recording_count=6,task_sample_count=42,query_group_count=18,
185
+ duration_samples=recipe['parent_static_duration_samples'],duration_s=recipe['parent_static_duration_samples']/SR,
186
+ output_step_s=.1,oracle_passed_samples=len(oracle),python_browser_parity=parity,
187
+ audio_checks=audio,rir_count=len(rendering['rir_records']),los_checked_rirs=len(los),
188
+ maximum_los_direct_angle_error_deg=max(r['direct_angle_error_deg'] for r in los),
189
+ maximum_native_final_50ms_energy_fraction=max(r['native_final_50ms_energy_fraction'] for r in rendering['rir_records']),
190
+ geometry_audit=geometry_audit,motion_observability=motion_observability,
191
+ human_listening_audit_completed=False,model_inference_performed=False)
192
+ if binaural:
193
+ report['binaural_postprocessing']=dict(passed=True,recordings=6,
194
+ original_foa_hashes_preserved=True,room_or_foa_regenerated=False,
195
+ preview_method=binaural['method'])
196
+ if recipe.get('continuous_speech_check'):
197
+ continuity=read(root/'data/continuity.json')
198
+ inspected=continuity['direct_component_check']
199
+ assert continuity['passed'] and inspected['passed']
200
+ assert inspected['coverage']>=.8 and inspected['p95_angle_error_deg']<3
201
+ assert inspected['maximum_adjacent_0_1s_angle_change_deg']<10
202
+ if work:
203
+ from .diagnostics import inspect_direct_component
204
+ scene=next(s for s in recipe['scenes'] if s['branch']=='easy_human')
205
+ repeated=inspect_direct_component(root,work,recipe,scene,scene['humans'][0],scene['robots'][0])
206
+ compare(inspected,repeated)
207
+ report['continuous_motion_audio_check']=dict(passed=True,source_id='H01',
208
+ isolated_foa_and_binaural_checked=6,
209
+ maximum_internal_silence_s=max((y[0]-x[1])/SR for x,y in zip(recipe['scenes'][0]['humans'][0]['events'][0]['activity_samples'],recipe['scenes'][0]['humans'][0]['events'][0]['activity_samples'][1:])),
210
+ direction_check_scope='First-arrival component of exact existing RIRs, easy_human/R01; full reverberant intensity estimates are descriptive only',
211
+ first_arrival_waveform_direction_check={k:inspected[k] for k in ['coverage','p95_angle_error_deg','maximum_adjacent_0_1s_angle_change_deg']})
212
+ write(root/'data/validation.json',report)
213
+ # Downloadable oracle is for checking the scorer, never claimed as predictions.
214
+ from .common import jsonl
215
+ jsonl(root/'data/oracle_predictions.jsonl',oracle)
216
+ print(json.dumps(report,ensure_ascii=False,indent=2))
217
+
218
+
219
+ if __name__=='__main__':
220
+ p=argparse.ArgumentParser();p.add_argument('--root',type=Path,required=True);p.add_argument('--work',type=Path);p.add_argument('--node')
221
+ a=p.parse_args();validate(a.root.resolve(),a.work.resolve() if a.work else None,a.node)
static/public/audio/test/5cd6ca88b6a6354719190189/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00c26d12e1263efb6d3f2cf91e671c82ac4af0e0910db9aebeea94f66b952de8
3
+ size 2816056
static/public/audio/test/5cd6ca88b6a6354719190189/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b6d68703168fc7823ee586a9a41264bc6043beaffaf315fddf7ccd1c082b898
3
+ size 2816056
static/public/audio/test/6227c8e456fc5c2abe229d39/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29de99fcd1a583164f1a24d2d145c17c1151e2df02107cd75fe7c297415af772
3
+ size 2944056
static/public/audio/test/6227c8e456fc5c2abe229d39/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8c962db548ebc7de330ee0782b40031ef23016696a1a024cfd8173a9b7c725e
3
+ size 2944056
static/public/audio/test/62813725c676711765a9f517/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:76e8e54fb80963b7c969b8be06176d9d11fc1001640d09823ed148c449c67ffe
3
+ size 3328056
static/public/audio/test/62813725c676711765a9f517/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6697031fd3c24232c58db35d2e5aa7b26f8b047cc422fd2fcc294f48e16fa07a
3
+ size 3328056
static/public/audio/test/70f37d9dc9eea6570196c752/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1239ed72ac387ee887bc3cd6b9813d46b3e503935d358c1d992ffc4723d93b4
3
+ size 2944056
static/public/audio/test/714ac7cf5d22ca4503e8d335/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fed945c4fba63b8b228dcd88a5c3b62f2694c6412a666fbf06301a333d351aa5
3
+ size 2688056
static/public/audio/test/714ac7cf5d22ca4503e8d335/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8ec08c90cef710609b1e33d5cd7747aaea196a7083c004a328d8223653b5f07
3
+ size 2688056
static/public/audio/test/7681c220a49f3aa111b8c969/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4cf1a09adf6ddbb1368e535f4e402e9d8ee3a6fd0cfc7e37a6cdab77cc12ff83
3
+ size 2816056
static/public/audio/test/7681c220a49f3aa111b8c969/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58923d7803a66a0c23d271a00913567b5d8e693e0c4de2712a2a8c1ca0fb4eda
3
+ size 2816056
static/public/audio/test/78012807030176bafef23d13/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41297eb16b5fdc38f88d27a2570b0e865f8de993a4912e0355de4a1964f78b24
3
+ size 3072056
static/public/audio/test/78012807030176bafef23d13/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fecfc287af33bd0386e13326d21894cfc7db33991d05289a864222594b3dc1d9
3
+ size 3072056
static/public/audio/test/7ab4ebddd1dcc83f4ee351bb/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d1b2b55078799c97c4d56b291da3409e200e565330eddef03aea0fa20e0c6460
3
+ size 3072056
static/public/audio/test/7ab4ebddd1dcc83f4ee351bb/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:07a121e58f244eb29b24293f13de9f18cc09d151a9cc1e5a8220d8bfd4bd239e
3
+ size 3072056
static/public/audio/test/7ab4ebddd1dcc83f4ee351bb/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6037366665357a94da1d0a7a4da576ff4a192525486b04c3a504aba60feb24d
3
+ size 3072056
static/public/audio/test/832b6dafe593bb3f8fe44ddf/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23324e7399303c22d90106efa733966b9ddb3baccf912f08960e5e40c92b12fd
3
+ size 3072056
static/public/audio/test/832b6dafe593bb3f8fe44ddf/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9ea23ee2a383403292ddfb791f3003ced1142fbe004d5651d44d12343f96196
3
+ size 3072056
static/public/audio/test/832b6dafe593bb3f8fe44ddf/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb06e80e00870d9dfc0c20edb7bcfb12c2522154100ddec8b0542b7050464c54
3
+ size 3072056
static/public/audio/test/8571c3158d8e3dd34ce02110/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e6444d7a064bb50f08a37e688d167f45325fda254458174956e5696579768911
3
+ size 3328056
static/public/audio/test/8571c3158d8e3dd34ce02110/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee9fc893af145579d2d6e9850098832a3163abcb1da27432b23097e4c453188e
3
+ size 3328056
static/public/audio/test/898f528190a6b19ece5a345b/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ad9d45896c99d44aa4030d8b2295b37ca91c4a6533b20e21d95e76147ee93db
3
+ size 5120056
static/public/audio/test/89c5e37d3786814006a7deed/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c97f8a069a793b6561858068571340174bf66f88fb8245c8532a949b8dc8392
3
+ size 3712056
static/public/audio/test/89c5e37d3786814006a7deed/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e25e2c1f03e7d7fbdfd6815ed56ef475c379b67ce4893f974b2b273cdf154f80
3
+ size 3712056
static/public/audio/test/89c5e37d3786814006a7deed/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:01b30a5a60b1567a7b94fd0d305906373b9ffccef4544e8d66717acccd10c530
3
+ size 3712056
static/public/audio/test/8c79bf31e6237444d57c18d1/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:752af5c1286e1e6fb21ce21f2cbf5a4162e99bc4caf9fd18cfb7a1d2017aa114
3
+ size 2816056
static/public/audio/test/8c79bf31e6237444d57c18d1/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2bbbcff16be2dea8193c502040ae480404a3a0e44e55a375739ee3189abc9165
3
+ size 2816056
static/public/audio/test/8c79bf31e6237444d57c18d1/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c3ca805fe18c1f4970f16c356b73fa2ff3c7066dd74ee401ae4e7808b94d2b8
3
+ size 2816056
static/public/audio/test/8f0b5e1379fe7d41646ac92a/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16364599f37253e7fa889377ec10eedfbf5125dbe16978fdad820e970e69ae10
3
+ size 3200056
static/public/audio/test/8f0b5e1379fe7d41646ac92a/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c80209685acd85b97d68982dd19804765f353745f16566124962df9ffb258116
3
+ size 3200056
static/public/audio/test/8f0b5e1379fe7d41646ac92a/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f001347b02f5f6cbc0bcd43271adfb3b02815bdce690eade54486fdf04cb5432
3
+ size 3200056
static/public/audio/test/999f3f6f30909bb0602f6035/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:361558a979680e137f1e83602b032e6c55a04aeeef3b7ab373aa4de7ffd7078a
3
+ size 2816056
static/public/audio/test/999f3f6f30909bb0602f6035/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d4d2409d8edfbb2ab3450a48146343933f9a3de9f27e4f9a63760ccfdbc4cf2
3
+ size 2816056
static/public/audio/test/999f3f6f30909bb0602f6035/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:57d083555b2e67236b1ff9d9663acf3a6d02ff60dec9ecd6c54bb4c22275c0cd
3
+ size 2816056
static/public/audio/test/a267981e8d98836e34903fc5/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4d93b6bac2de888d6fbbf932696cffa74fe1a171a54b334208f2d9d104cbab2
3
+ size 2688056
static/public/audio/test/a267981e8d98836e34903fc5/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4ba9010279c3f71c4d96a4caf13846a65b6298be93b33344838206963167b98b
3
+ size 2688056
static/public/audio/test/adb3360aee801d97a7d5e658/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:622006ff8bda30cc4df52cf9ab14004e8bd5655748715302c821ca316dff43b2
3
+ size 3200056
static/public/audio/test/adb3360aee801d97a7d5e658/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aea6bfdae1b917705b21bcf8fac656ef750f6b2f9b3c8576ded12afecde5b674
3
+ size 3200056
static/public/audio/test/adb3360aee801d97a7d5e658/R03_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fea899df14cae0d37616adccf3902e524d2fe3103e34c0aeb20f8a7454b369c2
3
+ size 3200056
static/public/audio/test/afedaa58abcadd37e4890c79/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e98075a43d6a847679a5c7c28bb88044a6799203aa5114b81f05ec0ca981636c
3
+ size 2688056
static/public/audio/test/b0560b662f87894178727d48/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ede11208d3b01bee2fbe69db38e03dace42d6550b95d2a452f76853f92a237db
3
+ size 2816056
static/public/audio/test/b0ce3c80e4ae4abeffbadb3c/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8d6b3d496c524c3fd8e70c8f906b7a77c3325e2975eb3cc4b2f54a2bf00ce04c
3
+ size 2688056
static/public/audio/test/b8627dee6b2252c9d0c83ba7/R01_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c60b253975a28470488ebcf265f5857381808de43110a4b7ce5c284c8ee2c21
3
+ size 2688056
static/public/audio/test/b9af50c644960c3036f5f20c/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5b67abb5b78bf7a3b1bd3e5386d7d53cd01856d61c685b6b68b4fe296d89c81
3
+ size 3200056
static/public/audio/test/bb6b7bc842c335944e50f300/R02_foa.wav ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:41901ffbe2b6c61be5c468fbdc01d255dae0f052330e6e2b293de139bfa7898d
3
+ size 2688056