fix(cartesia): guard HTTP session before use

Pyright flagged the .post() call on a possibly-None _session. Raise a
clear RuntimeError if start() wasn't called instead of crashing on the
attribute access.
This commit is contained in:
Mark Backman
2026-04-30 09:33:33 -04:00
parent e508642b0a
commit 3e5aabc5f2
2 changed files with 3 additions and 1 deletions

View File

@@ -42,7 +42,6 @@
"src/pipecat/services/azure/stt.py",
"src/pipecat/services/azure/tts.py",
"src/pipecat/services/cartesia/stt.py",
"src/pipecat/services/cartesia/tts.py",
"src/pipecat/services/deepgram/flux/base.py",
"src/pipecat/services/deepgram/flux/sagemaker/stt.py",
"src/pipecat/services/deepgram/flux/stt.py",

View File

@@ -916,6 +916,9 @@ class CartesiaHttpTTSService(TTSService):
logger.debug(f"{self}: Generating TTS [{text}]")
try:
if self._session is None:
raise RuntimeError("HTTP session is not initialized; call start() before run_tts()")
voice_config = {"mode": "id", "id": self._settings.voice}
output_format = {