Skip to content

feat(stv): support Human Presence audio batching and send timing - #29

Merged
mr-wanderer-x merged 6 commits into
mainfrom
feat/presence-small-audio-batches
Sep 28, 2026
Merged

mr-wanderer-x merged 6 commits into
mainfrom
feat/presence-small-audio-batches

Conversation

@mr-wanderer-x

@mr-wanderer-x mr-wanderer-x commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Human Presence clients can use smaller audio batches while retaining complete TTS bursts, and traces distinguish queued audio from completed socket writes. This PR contains the Presence SDK work for the small-chunk deployment; the Portrait server-hint work is maintained separately in #30 on fix/cancel-inflight-audio.

  • The documented Presence profile explicitly sets a 320 ms initial threshold, 200 ms subsequent minimum, 100 ms send gap, and server_feed_fixed_chunk_size=False. A 1-second TTS burst is sent whole once the threshold is met, subject to the existing transport cap.
  • Optional exact-size batching preserves complete PCM16 samples and flushes short tails without padding. It is disabled by default.
  • Cancellation retires the unsent remainder of an old payload even when cancellation completes during pacing or a socket write, preserving the next reply.
  • Tracing records audio_queued and completed audio_sent, including duration, queue/pacing wait, and write time. A completed write is not a server acknowledgement.

Both WebSocket playback and direct WebRTC use the shared feed. Global defaults remain 1,000 ms initial, 400 ms subsequent, and 200 ms gap; applications opt into the Presence profile. This branch does not consume server startup hints. Version: 0.11.1.

Validation: 255 hermetic tests passed, including both transports at 320 ms, whole-burst preservation, turn rearming, packet/sample boundaries, short tails, and cancellation races. Ruff format/lint, example checks, comment policy, locked dependency install, and wheel/sdist build passed. Pyright reports the same two pre-existing interaction_messages.py errors as main; CI type checking remains advisory. Live model sessions were not run.

The Ojin checkout was left unchanged during this split. Local verification and commits were performed directly because the helper-agent limit was reached; each commit's parent and tree were verified.

GitHub verify, examples, and build checks passed on the current head. The only check annotations are GitHub's upcoming Ubuntu runner-image migration notices; these are unrelated to the SDK changes.

Clients can opt into small audio packets without losing PCM samples or short tails, while retaining the existing batching defaults. Traces now distinguish queued audio from completed writes, and cancellation retires old in-flight audio without discarding the next reply.
@mr-wanderer-x
mr-wanderer-x marked this pull request as ready for review September 28, 2026 11:34
Avatar clients can use the server's recommended startup audio threshold without overriding explicit application settings or losing pending audio. Combine that negotiation with exact sample-aligned batching, accurate send timing, and the cancellation fix while retaining the 1000 ms fallback for servers without a valid hint.
@mr-wanderer-x mr-wanderer-x changed the title feat(stv): support precise audio batching and send timing feat(stv): tune startup audio from server hints and trace sends Sep 28, 2026
@mr-wanderer-x
mr-wanderer-x marked this pull request as draft September 28, 2026 12:52
Separate the Presence batching, send timing, and cancellation work from Portrait server hints. Verify the 320 ms profile sends larger TTS bursts intact and rearms for each turn.
@mr-wanderer-x mr-wanderer-x changed the title feat(stv): tune startup audio from server hints and trace sends feat(stv): support Human Presence audio batching and send timing Sep 28, 2026
@mr-wanderer-x
mr-wanderer-x marked this pull request as ready for review September 28, 2026 12:55
@mr-wanderer-x
mr-wanderer-x merged commit aa01226 into main Sep 28, 2026
3 checks passed
mr-wanderer-x added a commit that referenced this pull request Sep 29, 2026
Avatar replies should not wait for a fixed 1,000 ms of audio when the
server can start sooner. Both WebSocket and direct-WebRTC clients now
apply the server's startup audio recommendation before replaying
buffered TTS.

- `server_feed_initial_chunk_ms=None` selects automatic tuning. Valid
integer hints from 1–8,000 ms are accepted; missing or invalid hints
retain the 1,000 ms fallback. Explicit application settings always win.
- The documented Portrait profile uses 200 ms initial/subsequent
thresholds and a 100 ms send gap. These are explicit settings, not
global defaults. Larger TTS bursts remain whole unless fixed-size
batching is explicitly enabled.
- Startup hints and explicit settings use the same PCM16 sample rounding
in fixed-size mode, including 44.1 kHz. Queued audio survives
configuration and short tails flush without padding.

Merged current main (`aa01226`, Presence PR #29) into this branch.
Presence's explicit profile, optional exact-size batching, socket-send
timing, and cancellation-race fix are preserved. The cancellation
implementation is already on main and is not a new change in this PR.

Version: `0.12.0` (main: `0.11.1`).

Validation: all 286 hermetic unit tests pass, including Portrait and
Presence profiles, invalid hints, pre-session audio replay, whole-burst
preservation, fixed-size sample alignment, and cancellation during
pacing/socket writes. Locked dependency installation, Ruff format/lint,
example checks, comment policy, and wheel/sdist builds pass. Pyright
reports two existing errors in `interaction_messages.py`, which is
unchanged from main; the repository's type check is advisory. No live
bot/model session or deployment was performed.

GitHub verify, examples, and build checks passed on `cd8fc3d`. Their
only annotations are notices about the upcoming Ubuntu runner-image
migration; no product-code finding was reported.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant