diff --git a/.env.example b/.env.example index 71fdc19..9f5da77 100644 --- a/.env.example +++ b/.env.example @@ -38,7 +38,7 @@ ELEVENLABS_TTS_VOICE_ID= ELEVENLABS_TTS_MODEL_ID=eleven_flash_v2_5 ELEVENLABS_TTS_LANGUAGE_CODE=ru ELEVENLABS_TTS_OUTPUT_FORMAT=pcm_16000 -ELEVENLABS_TTS_SPEED=1.35 +ELEVENLABS_TTS_SPEED=1.2 ELEVENLABS_STT_MODEL_ID=scribe_v2 ELEVENLABS_STT_REALTIME_MODEL_ID=scribe_v2_realtime ELEVENLABS_STT_LANGUAGE_CODE=ru diff --git a/providers/tts.py b/providers/tts.py index 2641a37..d90afcc 100644 --- a/providers/tts.py +++ b/providers/tts.py @@ -53,6 +53,18 @@ def _parse_chunk_schedule(raw: str | None) -> list[int]: return values or [80, 120, 160, 220] +def _max_min(value: float, low: float, high: float) -> float: + try: + v = float(value) + except Exception: + v = low + if v < low: + return low + if v > high: + return high + return v + + def _sample_rate_from_pcm_format(output_format: str) -> int | None: normalized = str(output_format or "").strip().lower() if not normalized.startswith("pcm_"): @@ -131,7 +143,7 @@ class ElevenLabsTTS(BaseTTS): self._voice_settings = { "stability": self._read_float_env("ELEVENLABS_TTS_STABILITY", 0.5), "similarity_boost": self._read_float_env("ELEVENLABS_TTS_SIMILARITY_BOOST", 0.75), - "speed": self._read_float_env("ELEVENLABS_TTS_SPEED", 1.15), + _max_min(self._read_float_env("ELEVENLABS_TTS_SPEED", 1.15), 0.7, 1.2), "use_speaker_boost": self._read_bool_env("ELEVENLABS_TTS_USE_SPEAKER_BOOST", True), } LOGGER.info(