Skip to content

Commit 336171e

Browse files
committed
lazy import cartesia
1 parent fd15758 commit 336171e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

vocode/streaming/synthesizer/cartesia_synthesizer.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import io
22
import wave
33

4-
from cartesia.tts import AsyncCartesiaTTS
5-
64
from vocode import getenv
75
from vocode.streaming.models.message import BaseMessage
86
from vocode.streaming.models.synthesizer import CartesiaSynthesizerConfig
97
from vocode.streaming.synthesizer.base_synthesizer import BaseSynthesizer, SynthesisResult
108

119

1210
class CartesiaSynthesizer(BaseSynthesizer[CartesiaSynthesizerConfig]):
11+
cartesia_tts = None
12+
1313
def __init__(
1414
self,
1515
synthesizer_config: CartesiaSynthesizerConfig,
1616
):
1717
super().__init__(synthesizer_config)
1818

19+
# Lazy import the cartesia module
20+
if CartesiaSynthesizer.cartesia_tts is None:
21+
from cartesia.tts import AsyncCartesiaTTS
22+
CartesiaSynthesizer.cartesia_tts = AsyncCartesiaTTS
23+
1924
self.api_key = getenv("CARTESIA_API_KEY")
2025
self.model_id = synthesizer_config.model_id
2126
self.voice_id = synthesizer_config.voice_id

0 commit comments

Comments
 (0)