Skip to content

feat(enhancement): add CAMB AI audio enhancement for dictionary lookups#504

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

feat(enhancement): add CAMB AI audio enhancement for dictionary lookups#504
neilruaro-camb wants to merge 1 commit intoarianneorpilla: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 an audio enhancement option in jidoujisho, alongside Forvo and JapanesePod101. The clean AudioEnhancement plugin pattern made this very easy to slot in. We hope this complements the existing community recordings, especially for rare words and for languages where Forvo coverage is thin.

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

What this PR does

  • New file yuuna/lib/src/creator/enhancements/cambai_audio_enhancement.dart extends the existing AudioEnhancement abstract class. Same shape as ForvoAudioEnhancement and JapanesePod101AudioEnhancement.
  • No new Dart dependency: uses package:http that the other enhancements already pull in.
  • Registered in app_model.dart's populateEnhancements() and added to the default enhancement slot maps in anki_mapping.dart (both Japanese and non Japanese profiles), so fresh installs get the CAMB AI button alongside the Forvo and JapanesePod101 buttons in the card creator's audio field.
  • For Japanese, the kana reading is preferred over kanji as the TTS input so pronunciation is correct (for example with reading ねこ sends ねこ to Camb).
  • Generated mp3s are cached in getApplicationSupportDirectory()/cambAiAudio/ keyed by language, voice id, and a hash of the text, so repeat lookups are instant and offline once cached.
  • ISO-639-1 to BCP-47 mapping table covering the 16 languages Camb currently supports.

How a user turns it on

The API key is read from String.fromEnvironment('CAMB_API_KEY'), so users pass it at build time:

flutter build ios --dart-define=CAMB_API_KEY=<your key>
# or for development:
flutter run --dart-define=CAMB_API_KEY=<your key>

The build time define keeps this first iteration minimal. A natural follow up would be a Hive backed settings field next to the other enhancement settings, mirroring the existing pattern.

After install, in the card creator screen, users either tap the CAMB AI button directly in the audio field, or set it as the auto enhancement for the audio field in Settings.

Testing

No new unit tests, which matches the existing convention in yuuna/lib/src/creator/enhancements/ (neither forvo_audio_enhancement.dart nor japanesepod101_audio_enhancement.dart has unit tests). Verified by code review against those two existing implementations and by exercising the underlying Camb endpoint independently.

About Camb AI

  • Studio: https://studio.camb.ai
  • Docs: https://docs.camb.ai
  • Custom models in the mars family. This integration uses mars-pro for higher quality, since dictionary lookups are not latency critical and the audio is cached after the first request.

Adds a third audio enhancement alongside Forvo and JapanesePod101 so
that words without community recordings can still be pronounced. Uses
the same AudioEnhancement abstract class pattern, registered in the
default mapping for both Japanese and non Japanese profiles.

For Japanese, the kana reading is preferred over kanji as the TTS
input so pronunciation is correct. Generated mp3s are cached in the
application support directory keyed by language, voice id, and a hash
of the text, so repeat lookups are instant.

No new Dart dependency: uses the package:http already bundled with the
other enhancements.

Configuration:
  flutter build ios --dart-define=CAMB_API_KEY=<key>
  # or
  flutter run --dart-define=CAMB_API_KEY=<key>

The build time define keeps this first iteration minimal. A follow up
can move the key to a Hive backed settings field next to the other
enhancement settings.
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