Skip to content

feat(audios): add CAMB AI as a TTS provider option#3428

Open
neilruaro-camb wants to merge 1 commit intokantord:mainfrom
neilruaro-camb:feature/camb-ai-tts-provider
Open

feat(audios): add CAMB AI as a TTS provider option#3428
neilruaro-camb wants to merge 1 commit intokantord:mainfrom
neilruaro-camb:feature/camb-ai-tts-provider

Conversation

@neilruaro-camb
Copy link
Copy Markdown

Hi from Camb AI

We are Camb AI, the localization engine of choice for brands like the Premier League, NBA, NASCAR, and the Australian Open. We work with rightsholders and platforms who need high quality, low latency text to speech and dubbing in dozens of languages.

We'd love to be added as a TTS option in LibreLingo, alongside the existing AWS Polly path. This PR keeps the change small, opt in, and behind the existing Settings.Audio.TTS configuration surface, so it is easy to review and merge without affecting current courses.

Happy to iterate on naming, defaults, docs, or anything else you'd prefer. Thanks for maintaining LibreLingo.

What this PR does

  • Adds a cambai branch alongside the existing polly branch in _generate_audio_with_tts (the if/else hook in src/librelingo_audios/update_audios.py that already had a comment inviting more providers).
  • New helper _synthesize_with_cambai calls Camb's /apis/tts-stream endpoint over HTTPS using urllib from the standard library, so no new Python dependency is added. Camb returns mp3 directly, so no post processing is needed.
  • ISO-639-1 to BCP-47 mapping table covering the 16 languages Camb currently supports.
  • Fixes a small pre existing bug where the generated index JSON's ttsProvider field was hardcoded to "Polly" regardless of the actual provider used. With this PR, the index correctly records whichever provider produced each audio file.
  • Polly remains the default; CambAI is opt in via YAML; unknown providers raise a clear error rather than failing silently.

How a user turns it on

  1. export CAMB_API_KEY=<your key> (get one at https://studio.camb.ai).
  2. In the course's course.yaml, under Settings.Audio.TTS, add an entry:
    Settings:
      Audio:
        Enabled: True
        TTS:
          - Provider: CambAI
            Voice: "170460"     # numeric voice_id from /list-voices
            Engine: mars-pro    # speech_model: mars-pro for quality, mars-flash for low latency
  3. Run the existing CLI: librelingo-audios <course-dir> <audio-out-dir> <name>.
  4. Camb generated mp3s are written to the output directory keyed by phrase hash, just like Polly outputs.

Testing

5 new pytest cases in src/librelingo_audios/tests/test_cambai_provider.py covering:

  • Happy path: API call shape, file write, four phrases generated.
  • Index entry records the correct provider, voice, engine.
  • Missing CAMB_API_KEY env var raises a clear error.
  • Non numeric voice id raises a clear error pointing at /list-voices.
  • Unknown provider name raises a clear error.

Full audio test suite passes locally: 25 of 25 tests in src/librelingo_audios/tests/.

About Camb AI

  • Studio: https://studio.camb.ai
  • Docs: https://docs.camb.ai
  • Custom models in the mars family, with mars-flash at about 150ms latency for real time use and mars-pro for higher quality offline generation, which is the right fit for course build time TTS.

Adds CambAI alongside the existing AWS Polly path in
_generate_audio_with_tts so course authors can synthesise lesson
audio with CAMB's mars-pro / mars-flash voices.

The change is opt in: courses keep using Polly unless their
course.yaml declares Provider: CambAI under Settings.Audio.TTS. No new
Python dependency is introduced; the call uses urllib from the standard
library and mp3 is requested directly so no post processing is needed.

Also fixes a small pre existing bug where the ttsProvider field in the
generated index JSON was hardcoded to "Polly" regardless of the actual
provider used.

Configuration:
  export CAMB_API_KEY=<key>
  # in course.yaml:
  Settings:
    Audio:
      Enabled: True
      TTS:
        - Provider: CambAI
          Voice: "170460"
          Engine: mars-pro
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