Skip to content

examples: realtime speech-to-speech translation (mic + file)#24

Merged
arnavmehta7 merged 1 commit into
to-main/feat/realtime-speech-to-speech-translation-integrationfrom
feat/realtime-examples
May 27, 2026
Merged

examples: realtime speech-to-speech translation (mic + file)#24
arnavmehta7 merged 1 commit into
to-main/feat/realtime-speech-to-speech-translation-integrationfrom
feat/realtime-examples

Conversation

@arnavmehta7

Copy link
Copy Markdown
Collaborator

Summary

Adds two runnable examples for the new camb.realtime module (this PR targets the realtime feature branch, not main):

  • examples/realtime_translation_microphone.py — mic in (24 kHz PCM16) → plays translated audio out via sounddevice, 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.updatewait_until_ready() → stream input_audio_buffer.append → handle AUDIO_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:

model session.created translated audio text/transcript
iris ✅ ~full clip none observed
lilac ✗ (silent → 1006) none
orchid ✗ (silent → 1006) none
violet ✗ (timeout) none

So the examples default to model="iris" — the only model returning translated audio in testing. Note the SDK's own default is lilac (options.py), which returned no output; worth a look. No model emitted response.text.* / transcript.completed events 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 WAV
  • CAMB_API_KEY=… python examples/realtime_translation_microphone.py → hear translated audio

🤖 Generated with Claude Code

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>
@arnavmehta7 arnavmehta7 merged commit 31de616 into to-main/feat/realtime-speech-to-speech-translation-integration May 27, 2026
10 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