Skip to content

Commit

Permalink
support speed param when calling OpenAI TTS (livekit#412)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael <[email protected]>
  • Loading branch information
minhpq331 and michael-castalk authored Jul 4, 2024
1 parent 70bc061 commit c7f3c8e
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class _TTSOptions:
voice: TTSVoices
api_key: str
endpoint: str
speed: float


class TTS(tts.TTS):
Expand All @@ -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,
Expand All @@ -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

Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit c7f3c8e

Please sign in to comment.