feat(realtime): add realtime speech translation WebSocket client#23
Merged
arnavmehta7 merged 3 commits intoMay 27, 2026
Merged
Conversation
Implements camb.realtime, a new module that wraps the /v1/realtime WebSocket endpoint. Mirrors the live_transcription module's session, event dispatch, and transport patterns. Key behaviours: - connect() opens the WS, sends session.update with auth and config, and returns immediately; callers register handlers then await session.wait_until_ready() (90 s timeout) for session.created - Binary frames and JSON response.audio.delta both dispatch to AudioDeltaEvent with uniform data: bytes — handlers see no difference - session.starting is a supported event so callers can show a loading indicator during the 30+ s cold-boot of non-iris models - stream_audio() accepts any AsyncIterable[bytes], making it compatible with live_transcription.Microphone and FileAudioSource Wires client.realtime property onto both CambAI and AsyncCambAI.
Two runnable examples for the new camb.realtime module: - realtime_translation_microphone.py: mic in (24kHz PCM16) -> plays translated audio out via sounddevice, prints translated text. - realtime_translation_file.py: streams a 24kHz mono WAV -> writes the translated audio to an output WAV (headless-testable). Both use model="iris": in live testing against realtime.camb.ai it was the only model that returned translated audio (lilac/orchid connected but emitted nothing; violet never reached session.created). Audio is PCM16 mono 24kHz in both directions. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
examples: realtime speech-to-speech translation (mic + file)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements camb.realtime, a new module that wraps the /v1/realtime WebSocket endpoint. Mirrors the live_transcription module's session, event dispatch, and transport patterns. Key behaviours:
Wires client.realtime property onto both CambAI and AsyncCambAI.