fix: add language field to CartesiaTTSConfiguration and pass to Cartesia TTS service (#442)

* fix: add language field to CartesiaTTSConfiguration and pass to TTS service

Closes #432

* chore: regenerate OpenAPI spec to fix drift-check

The openapi.json snapshot had drifted from the FastAPI app definition
because main gained new organization endpoints (billing, credits,
context) after this branch was created. Regenerate it with
'python -m scripts.dump_docs_openapi' to bring it back in sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: clarify Cartesia language schema

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
nuthalapativarun 2026-06-18 00:53:27 -07:00 committed by GitHub
parent abfd5e4cdd
commit 788ff94cec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 40 additions and 1 deletions

View file

@ -978,6 +978,11 @@ class CartesiaTTSConfiguration(BaseTTSConfiguration):
le=2.0,
description="Volume multiplier for generated speech.",
)
language: str = Field(
default="en",
description="Cartesia language code for TTS synthesis (e.g. 'en', 'tr', 'fr', 'de').",
json_schema_extra={"allow_custom_input": True},
)
@register_tts

View file

@ -452,11 +452,13 @@ def create_tts_service(
generation_config = (
GenerationConfig(**gen_config_kwargs) if gen_config_kwargs else None
)
language = getattr(user_config.tts, "language", None) or "en"
return CartesiaTTSService(
api_key=user_config.tts.api_key,
settings=CartesiaTTSSettings(
voice=user_config.tts.voice,
model=user_config.tts.model,
language=language,
**(
{"generation_config": generation_config}
if generation_config

View file

@ -43,3 +43,35 @@ def test_create_cartesia_tts_service_passes_selected_model():
assert kwargs["api_key"] == "test-key"
assert kwargs["settings"].model == "sonic-3.5"
assert kwargs["settings"].voice == "test-voice-id"
def test_cartesia_tts_configuration_default_language_is_english():
config = CartesiaTTSConfiguration(api_key="test-key")
assert config.language == "en"
def test_create_cartesia_tts_service_passes_language_to_settings():
user_config = SimpleNamespace(
tts=SimpleNamespace(
provider=ServiceProviders.CARTESIA.value,
api_key="test-key",
model="sonic-3.5",
voice="test-voice-id",
speed=1.0,
volume=1.0,
language="tr",
)
)
audio_config = SimpleNamespace(
transport_out_sample_rate=24000,
transport_in_sample_rate=16000,
)
with patch(
"api.services.pipecat.service_factory.CartesiaTTSService"
) as mock_service:
create_tts_service(user_config, audio_config)
kwargs = mock_service.call_args.kwargs
assert kwargs["settings"].language == "tr"

File diff suppressed because one or more lines are too long