From c7f3c8e067087dea40527f2a29dd911fbb1d40d1 Mon Sep 17 00:00:00 2001 From: Minh Monmen Date: Thu, 4 Jul 2024 20:44:46 +0700 Subject: [PATCH] support speed param when calling OpenAI TTS (#412) Co-authored-by: Michael --- .../livekit-plugins-openai/livekit/plugins/openai/tts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/tts.py b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/tts.py index 288b56267..273c32840 100644 --- a/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/tts.py +++ b/livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/tts.py @@ -38,6 +38,7 @@ class _TTSOptions: voice: TTSVoices api_key: str endpoint: str + speed: float class TTS(tts.TTS): @@ -49,6 +50,7 @@ def __init__( api_key: str | None = None, base_url: str | None = None, http_session: aiohttp.ClientSession | None = None, + speed: float = 1.0, ) -> None: super().__init__( streaming_supported=False, @@ -65,6 +67,7 @@ def __init__( voice=voice, api_key=api_key, endpoint=os.path.join(get_base_url(base_url), "audio/speech"), + speed=speed, ) self._session = http_session @@ -102,6 +105,7 @@ async def _run(self): "model": self._opts.model, "voice": self._opts.voice, "response_format": "mp3", + "speed": self._opts.speed, }, ) as resp: async for data, _ in resp.content.iter_chunks():