Update Camb.ai TTS inference options
This commit is contained in:
@@ -74,9 +74,6 @@ async def main(voice_id: int):
|
|||||||
aiohttp_session=session,
|
aiohttp_session=session,
|
||||||
voice_id=voice_id,
|
voice_id=voice_id,
|
||||||
model="mars-flash",
|
model="mars-flash",
|
||||||
params=CambTTSService.InputParams(
|
|
||||||
speed=1.0,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# OpenAI LLM
|
# OpenAI LLM
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ Features:
|
|||||||
- 140+ languages supported
|
- 140+ languages supported
|
||||||
- Real-time HTTP streaming
|
- Real-time HTTP streaming
|
||||||
- 24kHz audio output
|
- 24kHz audio output
|
||||||
- Voice customization (speed, instructions)
|
- Voice customization (instructions for mars-instruct)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -129,8 +129,7 @@ class CambTTSService(TTSService):
|
|||||||
"""Camb.ai MARS HTTP-based text-to-speech service.
|
"""Camb.ai MARS HTTP-based text-to-speech service.
|
||||||
|
|
||||||
Converts text to speech using Camb.ai's MARS TTS models with support for
|
Converts text to speech using Camb.ai's MARS TTS models with support for
|
||||||
multiple languages. Provides control over voice characteristics like speed
|
multiple languages. Provides custom instructions support for the mars-instruct model.
|
||||||
and custom instructions (for mars-instruct model).
|
|
||||||
|
|
||||||
Example::
|
Example::
|
||||||
|
|
||||||
@@ -140,8 +139,7 @@ class CambTTSService(TTSService):
|
|||||||
model="mars-flash",
|
model="mars-flash",
|
||||||
aiohttp_session=session,
|
aiohttp_session=session,
|
||||||
params=CambTTSService.InputParams(
|
params=CambTTSService.InputParams(
|
||||||
language=Language.EN,
|
language=Language.EN
|
||||||
speed=1.0
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -163,13 +161,11 @@ class CambTTSService(TTSService):
|
|||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
language: Language for synthesis (BCP-47 format). Defaults to English.
|
language: Language for synthesis (BCP-47 format). Defaults to English.
|
||||||
speed: Speech speed multiplier (0.5 to 2.0). Defaults to 1.0.
|
|
||||||
user_instructions: Custom instructions for mars-instruct model only.
|
user_instructions: Custom instructions for mars-instruct model only.
|
||||||
Ignored for other models. Max 1000 characters.
|
Ignored for other models. Max 1000 characters.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
language: Optional[Language] = Language.EN
|
language: Optional[Language] = Language.EN
|
||||||
speed: Optional[float] = Field(default=1.0, ge=0.5, le=2.0)
|
|
||||||
user_instructions: Optional[str] = Field(
|
user_instructions: Optional[str] = Field(
|
||||||
default=None,
|
default=None,
|
||||||
max_length=1000,
|
max_length=1000,
|
||||||
@@ -223,7 +219,6 @@ class CambTTSService(TTSService):
|
|||||||
if params.language
|
if params.language
|
||||||
else DEFAULT_LANGUAGE
|
else DEFAULT_LANGUAGE
|
||||||
),
|
),
|
||||||
"speed": params.speed or 1.0,
|
|
||||||
"user_instructions": params.user_instructions,
|
"user_instructions": params.user_instructions,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,7 +307,6 @@ class CambTTSService(TTSService):
|
|||||||
"language": self._settings["language"],
|
"language": self._settings["language"],
|
||||||
"speech_model": self._model_name,
|
"speech_model": self._model_name,
|
||||||
"output_configuration": {"format": "pcm_s16le"},
|
"output_configuration": {"format": "pcm_s16le"},
|
||||||
"voice_settings": {"speed": self._settings["speed"]},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add user instructions if using mars-instruct model
|
# Add user instructions if using mars-instruct model
|
||||||
|
|||||||
@@ -336,17 +336,14 @@ async def test_input_params():
|
|||||||
# Test defaults
|
# Test defaults
|
||||||
params = CambTTSService.InputParams()
|
params = CambTTSService.InputParams()
|
||||||
assert params.language == Language.EN
|
assert params.language == Language.EN
|
||||||
assert params.speed == 1.0
|
|
||||||
assert params.user_instructions is None
|
assert params.user_instructions is None
|
||||||
|
|
||||||
# Test custom values
|
# Test custom values
|
||||||
params = CambTTSService.InputParams(
|
params = CambTTSService.InputParams(
|
||||||
language=Language.ES,
|
language=Language.ES,
|
||||||
speed=1.5,
|
|
||||||
user_instructions="Speak slowly and clearly",
|
user_instructions="Speak slowly and clearly",
|
||||||
)
|
)
|
||||||
assert params.language == Language.ES
|
assert params.language == Language.ES
|
||||||
assert params.speed == 1.5
|
|
||||||
assert params.user_instructions == "Speak slowly and clearly"
|
assert params.user_instructions == "Speak slowly and clearly"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user