Skip to content

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

Merged
munkhorgil merged 6 commits into
mainfrom
feat/stereo-recording-room-sid
Jun 1, 2026
Merged

feat: align stereo recording via RecorderIO and link calls to the room sid#5
munkhorgil merged 6 commits into
mainfrom
feat/stereo-recording-room-sid

Conversation

@munkhorgil

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 5 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>
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>
@claude

claude Bot commented Jun 1, 2026

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

Removes the OTLP tracer setup, its dependencies, and the related docs from the
example. The room sid -> livekit_call_id mapping is kept (it's the id Roark keys
the call on); only the trace-export demonstration is removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@munkhorgil munkhorgil force-pushed the feat/stereo-recording-room-sid branch from e4d89d8 to 89d77ef Compare June 1, 2026 07:24
@munkhorgil munkhorgil merged commit 34f2158 into main Jun 1, 2026
4 checks passed
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