feat: add CAMB AI TTS integration (#187)

Co-authored-by: Abhishek <abhishek@a6k.me>
This commit is contained in:
neil from camb.ai 2026-03-24 15:24:07 +08:00 committed by GitHub
parent 330e4a05f2
commit 31e075d114
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 244 additions and 4 deletions

View file

@ -38,6 +38,7 @@ class UserConfigurationValidator:
ServiceProviders.DOGRAH.value: self._check_dograh_api_key,
ServiceProviders.SARVAM.value: self._check_sarvam_api_key,
ServiceProviders.SPEECHMATICS.value: self._check_speechmatics_api_key,
ServiceProviders.CAMB.value: self._check_camb_api_key,
ServiceProviders.AWS_BEDROCK.value: self._check_aws_bedrock_api_key,
}
@ -160,6 +161,9 @@ class UserConfigurationValidator:
def _check_speechmatics_api_key(self, model: str, api_key: str) -> bool:
return True
def _check_camb_api_key(self, model: str, api_key: str) -> bool:
return True
def _check_aws_bedrock_api_key(self, model: str, service_config) -> bool:
if not service_config.aws_access_key or not service_config.aws_secret_key:
raise ValueError("AWS access key and secret key are required for Bedrock")

View file

@ -25,6 +25,7 @@ class ServiceProviders(str, Enum):
DOGRAH = "dograh"
SARVAM = "sarvam"
SPEECHMATICS = "speechmatics"
CAMB = "camb"
AWS_BEDROCK = "aws_bedrock"
@ -423,6 +424,19 @@ class SarvamTTSConfiguration(BaseTTSConfiguration):
)
CAMB_TTS_MODELS = ["mars-flash", "mars-pro", "mars-instruct"]
@register_tts
class CambTTSConfiguration(BaseTTSConfiguration):
provider: Literal[ServiceProviders.CAMB] = ServiceProviders.CAMB
model: str = Field(
default="mars-flash", json_schema_extra={"examples": CAMB_TTS_MODELS}
)
voice: str = Field(default="147320", description="Camb.ai voice ID")
language: str = Field(default="en-us", description="BCP-47 language code")
TTSConfig = Annotated[
Union[
DeepgramTTSConfiguration,
@ -431,6 +445,7 @@ TTSConfig = Annotated[
CartesiaTTSConfiguration,
DograhTTSService,
SarvamTTSConfiguration,
CambTTSConfiguration,
],
Field(discriminator="provider"),
]

View file

@ -237,6 +237,20 @@ def create_tts_service(user_config, audio_config: "AudioConfig"):
text_filters=[xml_function_tag_filter],
silence_time_s=1.0,
)
elif user_config.tts.provider == ServiceProviders.CAMB.value:
from pipecat.services.camb.tts import CambTTSService
voice_id = int(getattr(user_config.tts, "voice", None) or "147320")
language = getattr(user_config.tts, "language", None) or "en-us"
tts = CambTTSService(
api_key=user_config.tts.api_key,
voice_id=voice_id,
model=user_config.tts.model,
text_filters=[xml_function_tag_filter],
)
# Set language directly as BCP-47 code (bypasses Language enum conversion)
tts._settings.language = language
return tts
elif user_config.tts.provider == ServiceProviders.SARVAM.value:
# Map Sarvam language code to pipecat Language enum for TTS
language_mapping = {