This commit is contained in:
Konturai DevOps
2026-05-01 17:50:41 +05:00
parent 1f07c710e1
commit d4d8555bd9
10 changed files with 87 additions and 26 deletions
+6 -3
View File
@@ -119,11 +119,15 @@ class ElevenLabsTTS(BaseTTS):
str(output_format or os.getenv("ELEVENLABS_TTS_OUTPUT_FORMAT", "pcm_16000")).strip().lower()
or "pcm_16000"
)
requested_sample_rate_hz = _sample_rate_from_pcm_format(requested_output_format)
self._target_sample_rate_hz = int(
target_sample_rate_hz
if target_sample_rate_hz is not None
else (_sample_rate_from_pcm_format(requested_output_format) or 16000)
else (requested_sample_rate_hz or 16000)
)
if self._target_sample_rate_hz == 8000:
LOGGER.warning("ElevenLabs TTS target sample rate 8000Hz is disabled; using 16000Hz")
self._target_sample_rate_hz = 16000
self._output_format = self._resolve_provider_output_format(
requested_output_format=requested_output_format,
target_sample_rate_hz=self._target_sample_rate_hz,
@@ -381,8 +385,7 @@ class ElevenLabsTTS(BaseTTS):
normalized = requested_output_format.strip().lower() or "pcm_16000"
if normalized == "pcm_8000":
LOGGER.warning(
"ElevenLabs TTS does not provide reliable PCM16 8kHz streaming; requesting pcm_16000 "
"and resampling to %sHz locally",
"ElevenLabs TTS PCM16 8kHz output is disabled; requesting pcm_16000 for %sHz target",
target_sample_rate_hz,
)
return "pcm_16000"