File size: 1,337 Bytes
06f9561
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
from __future__ import annotations


AUDIO_RATE = 16_000
MOTION_FPS = 50
AUDIO_WINDOW_SECONDS = 0.6
# Qwen consumes one overlapping audio window every 0.4 seconds.
AUDIO_STRIDE_FRAMES = 20
# Dense action supervision shifts the current state by one 50 Hz frame.
ACTION_SAMPLE_STEP_FRAMES = 1
ACTION_CHUNK_FRAMES = 30
ACTION_EXEC_FRAMES = 20
RTC_PREFIX_FRAMES = 10


def complete_audio_clip_starts(
    total_samples: int,
    *,
    sampling_rate: int = AUDIO_RATE,
    window_seconds: float = AUDIO_WINDOW_SECONDS,
    stride_frames: int = AUDIO_STRIDE_FRAMES,
    motion_fps: int = MOTION_FPS,
) -> list[int]:
    """Return the exact complete-window starts used by the training exporter."""

    window_samples = int(round(float(window_seconds) * int(sampling_rate)))
    stride_samples = int(round(int(stride_frames) / float(motion_fps) * int(sampling_rate)))
    if total_samples < window_samples:
        return []
    return list(range(0, int(total_samples) - window_samples + 1, stride_samples))


def aligned_motion_start_frame(
    total_samples: int,
    *,
    sampling_rate: int = AUDIO_RATE,
    motion_fps: int = MOTION_FPS,
) -> int:
    """First motion frame at or after the exact decoded audio end sample."""

    return (int(total_samples) * int(motion_fps) + int(sampling_rate) - 1) // int(
        sampling_rate
    )