"""Blind-model prompts with public receiver poses and task-specific cues only.""" from __future__ import annotations import json from .common import SR,grid,position def robot_poses(scene): return [dict(robot_id=r['entity_id'],yaw_deg=round(r['yaw_deg']),height_m=round(r['initial_xyz_m'][1],1), positions=[[s/SR]+[round(float(x),1) for x in position(r,s/SR)] for s in grid(scene)]) for r in scene['robots']] def playback_log(scene): return [dict(robot_id=r['entity_id'],start_sample=e['start_sample'],end_sample=e['end_sample'], start_time_s=e['start_sample']/SR,end_time_s=e['end_sample']/SR,text=e['text']) for r in scene['playback_sources'] for e in r['events']] def render(scene,task,query,receiver_ids,reference=None): lines=['You are given FOA recordings of the same dynamic multi-speaker scene.'] lines.extend(r+': <|AUDIO|><|spatial|>' for r in receiver_ids) lines.extend([f"Audio covers [0.000, {scene['duration_samples']/SR:.3f}) seconds on one synchronized scene clock.", 'Use scene times 0.0, 0.2, 0.4, ... strictly before the end of the supplied recording.', 'Spatial labels refer to the physical source at that scene time; propagation delay remains in the audio.', 'Each recording has its own robot playback ideally removed. Other robot playback is interference, never a human target.', 'FOA: 16 kHz, ACN/SN3D [W,Y,Z,X]. Receiver-local X is front, Y is left, Z is up.', 'World [x,y,z] coordinates are meters; +y is up. Robot yaw 0 faces world -z; positive yaw turns toward +x.', 'Robots may translate horizontally; yaw and height remain fixed. Known positions are rounded to 0.1 m, yaw to whole degrees.', 'Known robot poses; each row is [time_s,x,y,z]:']) for pose in robot_poses(scene):lines.append(pose['robot_id']+f": yaw {pose['yaw_deg']} degrees; "+json.dumps(pose['positions'],separators=(',',':'))) lines.append('Known robot playback log:') for e in playback_log(scene):lines.append(e['robot_id']+f": [{e['start_time_s']:.3f},{e['end_time_s']:.3f}) s; text "+json.dumps(e['text'])) if reference:lines.extend(['Use '+reference+' as the direction/distance reference at each time.', 'Azimuth: front 0 degrees, left +90, right -90; elevation is positive upwards. Output absolute DOA, not angular changes.']) if task=='DOA_TRAJECTORY': lines.extend([f"Return {len(scene['humans'])} human speaker tracks, preserving one stable arbitrary track_id per person across the entire clip.", 'Return JSON {"tracks":[{"track_id":"S1","frames":[{"time_s":0.0,"active":false}, ...]}, ...]}.', 'Every track must contain every requested grid time. active means emitted speech, excluding natural phonetic pauses and reverberation-only tails.', 'For active=true add "doa_deg":[azimuth,elevation] in degrees. Use azimuth in [-180,180] and elevation in [-90,90]. For active=false omit doa_deg.']) elif task=='RANGE_TRAJECTORY': a,b=query['cue_time_range_s'];lo,hi=query['initial_sector_deg'] lines.extend([f"At {query['selection_time_s']:.3f} s, select the human EMITTING SPEECH whose azimuth lies in [{lo},{hi}) degrees. Use [{a:.3f},{b:.3f}) s as the initial listening cue window.", 'This initial time and sector select one person. Keep following that person after they move outside the sector.', 'Return JSON {"frames":[{"time_s":0.0,"active":false}, ...]} with every requested grid time.', 'For target speech use active=true and add "distance_m": a positive distance from the current microphone. Otherwise use active=false and omit distance_m.']) elif task=='TEXT_TRAJECTORY': lines.extend(['Find the human saying '+json.dumps(query['transcript'])+'.', 'Follow that same person during ALL their speech in the supplied clip.', 'Return JSON {"frames":[{"time_s":0.0,"active":false}, ...]} with every requested grid time.', 'During target speech use active=true and add "xyz_m":[x,y,z] in WORLD coordinates; otherwise use active=false and omit xyz_m.']) elif task=='KW_ASR': lines.extend(['The wake keyword/phrase is '+json.dumps(query['wake_phrase'])+'.', 'Each human contributes one contiguous emission segment. Its first spoken words define the utterance beginning; brief natural pauses do not restart this check.', 'Match consecutive whole words at the BEGINNING of a human utterance, ignoring case and punctuation. Repeated matches by the same person count as one speaker.', 'If exactly one distinct human matches, transcribe ALL of that person\'s speech in the input clip, including the wake phrase, in time order.', 'Ignore all other people and robot playback when transcribing. If zero or multiple humans match, return the literal empty string "".', 'Return only the English transcript or the literal empty string "". Do not add timestamps, labels, fields or explanations.']) else:raise ValueError('Unknown task: '+task) return '\n'.join(lines)