Skip to content

feat: align stereo recording via RecorderIO and link calls to the room sid#4

Closed
munkhorgil wants to merge 5 commits into
mainfrom
chore/prep-0.1.0-release
Closed

feat: align stereo recording via RecorderIO and link calls to the room sid#4
munkhorgil wants to merge 5 commits into
mainfrom
chore/prep-0.1.0-release

Conversation

@munkhorgil

@munkhorgil munkhorgil commented May 31, 2026

Copy link
Copy Markdown
Collaborator

Core improvements to the LiveKit → Roark integration. Not a release — changelog
entries stay under [Unreleased].

What's in here

  • Align stereo recording via livekit RecorderIO — channel alignment (each turn placed on the timeline, real silence spliced between turns, faster-than-real-time TTS bursts kept at their true duration) now reuses livekit-agents' own RecorderIO, so the recording matches what LiveKit would write to disk and transcript/tool markers (placed at audioOffsetMs) land correctly on the waveform. Sample rate is adopted from the negotiated stream (8 kHz telephony, 16/24/48 kHz WebRTC, …) and reported on call-ended as recordingSampleRate. Adds _recorder.py and reworks audio.py / session.py.
  • Link calls to the room sidlivekit_call_id now defaults to the LiveKit room sid so Roark can link the call to its OpenTelemetry trace. Prefers ctx.job.room.sid (available before ctx.connect()), falling back to the async ctx.room.sid, then the job id, then a random UUID.
  • Point the SDK at production api.roark.ai endpoints (both the webhook and chunk-upload lanes).
  • Example: wire OpenTelemetry export so LiveKit traces reach Roark (setup_roark_tracer, with the supporting deps).

Notes for the reviewer

  • CHANGELOG.md entries live under [Unreleased]; this PR does not cut a release.
  • Heads-up: pyproject.toml is at 0.1.0 with no v0.1.0 tag yet, and the Release workflow still fires on push to main, so squash-merging will trigger a publish attempt. It will no-op/fail unless a PyPI publisher is configured for the project.
  • Tests added/updated: test_recorder.py (new), test_audio.py, test_session.py.

🤖 Generated with Claude Code

munkhorgil and others added 3 commits May 31, 2026 20:38
Channel alignment is now delegated to livekit-agents' own RecorderIO,
subclassed as RoarkRecorderIO, which places each turn on the timeline,
splices real silence between turns, and keeps a faster-than-real-time TTS
burst at its true duration instead of collapsing it. The previous mixer
wrote each frame at its wall-clock arrival offset, which overlapped bursty
TTS into a sped-up, clipped channel and turned a jittery mic into a buzz.

audio.py is now purely the upload side (AudioCapture): it buffers the
interleaved PCM the recorder emits and ships it to Roark in chunks. The
recording sample rate is adopted from the negotiated stream rather than
fixed at 24 kHz, and reported on call-ended as recordingSampleRate.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Both the webhook and chunk-upload lanes now resolve against a single
https://api.roark.ai base instead of the dev stage and a localhost
upload service used during development.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This version has not shipped yet, so fold the prior Unreleased notes into
a single initial 0.1.0 entry that describes the integration as it actually
behaves on first release.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@claude

claude Bot commented May 31, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

munkhorgil and others added 2 commits May 31, 2026 21:57
observe_session now derives the call id from ctx.room.sid (the RM_… id
LiveKit Agents tags its OpenTelemetry spans with as room_id), falling back
to ctx.job.id then a random UUID. This lets Roark link a call to its trace
the same way the LiveKit Cloud integration does. Resolve the sid by calling
observe_session after ctx.connect().

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Prefer ctx.job.room.sid (available pre-connect) for the call id, falling
  back to the async ctx.room.sid, then job id, then a random UUID.
- Switch webhook and chunk-upload lanes to https://api.roark.ai.
- Example: wire OpenTelemetry export so LiveKit traces reach Roark.
- Changelog: keep entries under [Unreleased] (not a release yet).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@munkhorgil munkhorgil changed the title chore: prep 0.1.0 release feat: align stereo recording via RecorderIO and link calls to the room sid Jun 1, 2026
@munkhorgil munkhorgil closed this Jun 1, 2026
@munkhorgil munkhorgil deleted the chore/prep-0.1.0-release branch June 1, 2026 07:14
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