mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-01 08:59:46 +02:00
feat: add custom sarvam tts voice (#449)
* feat: add custom sarvam tts voice * chore: refactor registry and add deepgram multi --------- Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
This commit is contained in:
parent
344c8220de
commit
951e73a645
9 changed files with 268 additions and 69 deletions
|
|
@ -126,6 +126,13 @@ class TestSarvamTTSServiceFactory:
|
|||
assert config.language == "hi-IN"
|
||||
assert config.speed == 1.0
|
||||
|
||||
def test_sarvam_tts_voice_schema_allows_custom_model_specific_options(self):
|
||||
voice_schema = SarvamTTSConfiguration.model_json_schema()["properties"]["voice"]
|
||||
|
||||
assert voice_schema["allow_custom_input"] is True
|
||||
assert "bulbul:v2" in voice_schema["model_options"]
|
||||
assert "bulbul:v3" in voice_schema["model_options"]
|
||||
|
||||
def test_create_sarvam_tts_service_maps_speed_to_pace(self):
|
||||
user_config = SimpleNamespace(
|
||||
tts=SimpleNamespace(
|
||||
|
|
@ -152,3 +159,49 @@ class TestSarvamTTSServiceFactory:
|
|||
assert kwargs["settings"].voice == "anushka"
|
||||
assert kwargs["settings"].language == Language.HI
|
||||
assert kwargs["settings"].pace == 1.25
|
||||
|
||||
def test_create_sarvam_tts_service_normalizes_custom_voice_id(self):
|
||||
user_config = SimpleNamespace(
|
||||
tts=SimpleNamespace(
|
||||
provider=ServiceProviders.SARVAM.value,
|
||||
api_key="test-key",
|
||||
model="bulbul:v2",
|
||||
voice=" Rehan ",
|
||||
language="hi-IN",
|
||||
speed=1.0,
|
||||
)
|
||||
)
|
||||
audio_config = AudioConfig(
|
||||
transport_in_sample_rate=16000, transport_out_sample_rate=16000
|
||||
)
|
||||
|
||||
with patch(
|
||||
"api.services.pipecat.service_factory.SarvamTTSService"
|
||||
) as mock_service:
|
||||
create_tts_service(user_config, audio_config)
|
||||
|
||||
kwargs = mock_service.call_args.kwargs
|
||||
assert kwargs["settings"].voice == "rehan"
|
||||
|
||||
def test_create_sarvam_tts_service_defaults_blank_voice_id(self):
|
||||
user_config = SimpleNamespace(
|
||||
tts=SimpleNamespace(
|
||||
provider=ServiceProviders.SARVAM.value,
|
||||
api_key="test-key",
|
||||
model="bulbul:v2",
|
||||
voice=" ",
|
||||
language="hi-IN",
|
||||
speed=1.0,
|
||||
)
|
||||
)
|
||||
audio_config = AudioConfig(
|
||||
transport_in_sample_rate=16000, transport_out_sample_rate=16000
|
||||
)
|
||||
|
||||
with patch(
|
||||
"api.services.pipecat.service_factory.SarvamTTSService"
|
||||
) as mock_service:
|
||||
create_tts_service(user_config, audio_config)
|
||||
|
||||
kwargs = mock_service.call_args.kwargs
|
||||
assert kwargs["settings"].voice == "anushka"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue