mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-06-13 08:15:21 +02:00
feat: add CAMB AI TTS integration (#187)
Co-authored-by: Abhishek <abhishek@a6k.me>
This commit is contained in:
parent
330e4a05f2
commit
31e075d114
7 changed files with 244 additions and 4 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
]
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue