examples: realtime speech-to-speech translation (mic + file)#24
Merged
arnavmehta7 merged 1 commit intoMay 27, 2026
Conversation
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>
31de616
into
to-main/feat/realtime-speech-to-speech-translation-integration
10 checks passed
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.
Summary
Adds two runnable examples for the new
camb.realtimemodule (this PR targets the realtime feature branch, notmain):examples/realtime_translation_microphone.py— mic in (24 kHz PCM16) → plays translated audio out viasounddevice, prints translated text. Run:CAMB_API_KEY=… python examples/realtime_translation_microphone.py [src] [tgt]examples/realtime_translation_file.py— streams a 24 kHz mono WAV → writes translated audio to an output WAV (headless-testable, no mic/speaker needed).Both follow the documented protocol exactly:
connect()→session.update→wait_until_ready()→ streaminput_audio_buffer.append→ handleAUDIO_DELTA/TEXT_DONE/TRANSCRIPT_COMPLETED. Audio is PCM16 mono 24 kHz in both directions.Live testing notes (realtime.camb.ai)
Validated against the live endpoint. Per-model results:
So the examples default to
model="iris"— the only model returning translated audio in testing. Note the SDK's own default islilac(options.py), which returned no output; worth a look. No model emittedresponse.text.*/transcript.completedevents in testing (audio-only output), so the examples' text printing will currently stay blank while audio works.Test plan
CAMB_API_KEY=… python examples/realtime_translation_file.py input_24k_mono.wav→ writes translated WAVCAMB_API_KEY=… python examples/realtime_translation_microphone.py→ hear translated audio🤖 Generated with Claude Code