Compare commits

...

2 Commits

Author SHA1 Message Date
Mark Backman
6fca53c31d Add changelog for #4525 2026-05-19 18:32:02 -04:00
Mark Backman
e1f3b4fdbe raise ImportError instead of Exception for missing optional deps
Across 84 files, the optional-dependency guard at module load did
`raise Exception(f"Missing module: {e}")`, which is too generic and
drops the original `ModuleNotFoundError` traceback. Switch to
`raise ImportError(...) from e` so callers can `except ImportError:`
cleanly and the original cause is preserved.

Two files (audio/turn/krisp_viva_turn.py, turns/user_start/krisp_viva_ip_user_turn_start_strategy.py)
already used the correct pattern and were left untouched.
2026-05-19 18:31:25 -04:00
85 changed files with 87 additions and 86 deletions

View File

@@ -0,0 +1 @@
- Services and transports with missing optional dependencies now raise `ImportError` instead of a bare `Exception` when their module is imported without the required extra installed. The original `ModuleNotFoundError` is preserved as `__cause__`, so code that wraps these imports can now use `except ImportError:` cleanly instead of `except Exception:`.

View File

@@ -28,7 +28,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Google AI, you need to `pip install pipecat-ai[google]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class GeminiLLMInvocationParams(TypedDict):

View File

@@ -23,7 +23,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use the Koala filter, you need to `pip install pipecat-ai[koala]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class KoalaFilter(BaseAudioFilter):

View File

@@ -27,7 +27,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use KrispVivaFilter, you need to install krisp_audio.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class KrispVivaFilter(BaseAudioFilter):

View File

@@ -28,7 +28,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use the soundfile mixer, you need to `pip install pipecat-ai[soundfile]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class SoundfileMixer(BaseAudioMixer):

View File

@@ -27,7 +27,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use the LocalSmartTurnAnalyzer, you need to `pip install pipecat-ai[local-smart-turn]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class LocalCoreMLSmartTurnAnalyzer(BaseSmartTurn):

View File

@@ -33,7 +33,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use LocalSmartTurnAnalyzerV2, you need to `pip install pipecat-ai[local-smart-turn]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class LocalSmartTurnAnalyzerV2(BaseSmartTurn):

View File

@@ -28,7 +28,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use KrispVivaVADAnalyzer, you need to install krisp_audio.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class KrispVivaVadAnalyzer(VADAnalyzer):

View File

@@ -27,7 +27,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Silero VAD, you need to `pip install pipecat-ai`.")
raise Exception(f"Missing module(s): {e}")
raise ImportError(f"Missing module(s): {e}") from e
class SileroOnnxModel:

View File

@@ -22,7 +22,7 @@ try:
from langchain_core.runnables import Runnable
except ModuleNotFoundError as e:
logger.error("In order to use Langchain, you need to `pip install pipecat-ai[langchain]`. ")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class LangchainProcessor(FrameProcessor):

View File

@@ -21,7 +21,7 @@ try:
from strands.multiagent.graph import Graph
except ModuleNotFoundError as e:
logger.error("In order to use Strands Agents, you need to `pip install strands-agents`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class StrandsAgentsProcessor(FrameProcessor):

View File

@@ -33,7 +33,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use GStreamer, you need to `pip install pipecat-ai[gstreamer]`. Also, you need to install GStreamer in your system."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class GStreamerPipelineSource(FrameProcessor):

View File

@@ -17,7 +17,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Sentry, you need to `pip install pipecat-ai[sentry]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
from pipecat.processors.metrics.frame_processor_metrics import FrameProcessorMetrics

View File

@@ -48,7 +48,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Anthropic, you need to `pip install pipecat-ai[anthropic]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class AnthropicThinkingConfig(BaseModel):

View File

@@ -55,7 +55,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error('In order to use AssemblyAI, you need to `pip install "pipecat-ai[assemblyai]"`.')
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def map_language_from_assemblyai(language_code: str) -> Language:

View File

@@ -39,7 +39,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Async, you need to `pip install pipecat-ai[asyncai]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_async_language(language: Language) -> str:

View File

@@ -49,7 +49,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use AWS services, you need to `pip install pipecat-ai[aws]`. Also, remember to set `AWS_SECRET_ACCESS_KEY`, `AWS_ACCESS_KEY_ID`, and `AWS_REGION` environment variable."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -81,7 +81,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use AWS services, you need to `pip install pipecat-ai[aws-nova-sonic]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class AWSNovaSonicUnhandledFunctionException(Exception):

View File

@@ -32,7 +32,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use SageMaker BiDi client, you need to `pip install pipecat-ai[sagemaker]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class SageMakerBidiClient:

View File

@@ -48,7 +48,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use AWS services, you need to `pip install pipecat-ai[aws]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -34,7 +34,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use AWS services, you need to `pip install pipecat-ai[aws]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_aws_language(language: Language) -> str:

View File

@@ -17,7 +17,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Azure Realtime, you need to `pip install pipecat-ai[openai]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -49,7 +49,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Azure, you need to `pip install pipecat-ai[azure]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -42,7 +42,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Azure, you need to `pip install pipecat-ai[azure]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def sample_rate_to_output_format(sample_rate: int) -> SpeechSynthesisOutputFormat:

View File

@@ -42,7 +42,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Cartesia, you need to `pip install pipecat-ai[cartesia]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -39,7 +39,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Cartesia, you need to `pip install pipecat-ai[cartesia]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class GenerationConfig(BaseModel):

View File

@@ -31,7 +31,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Deepgram Flux, you need to `pip install pipecat-ai[deepgram]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Re-export for backward compatibility
__all__ = [

View File

@@ -48,7 +48,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Deepgram, you need to `pip install pipecat-ai[deepgram]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class LiveOptions:

View File

@@ -39,7 +39,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use DeepgramWebsocketTTSService, you need to `pip install pipecat-ai[deepgram]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -52,7 +52,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use ElevenLabs Realtime STT, you need to `pip install pipecat-ai[elevenlabs]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_elevenlabs_language(language: Language) -> str:

View File

@@ -56,7 +56,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use ElevenLabs, you need to `pip install pipecat-ai[elevenlabs]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Models that support language codes
# The following models are excluded as they don't support language codes:

View File

@@ -38,7 +38,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Fish Audio, you need to `pip install pipecat-ai[fish]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# FishAudio supports various output formats
FishAudioOutputFormat = Literal["opus", "mp3", "pcm", "wav"]

View File

@@ -53,7 +53,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Gladia, you need to `pip install pipecat-ai[gladia]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_gladia_language(language: Language) -> str:

View File

@@ -105,7 +105,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Google AI, you need to `pip install pipecat-ai[google]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Connection management constants

View File

@@ -36,7 +36,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Google Vertex AI, you need to `pip install pipecat-ai[google]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -35,7 +35,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Google AI, you need to `pip install pipecat-ai[google]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -65,7 +65,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Google AI, you need to `pip install pipecat-ai[google]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class GoogleThinkingConfig(BaseModel):

View File

@@ -57,7 +57,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Google AI, you need to `pip install pipecat-ai[google]`. Also, set `GOOGLE_APPLICATION_CREDENTIALS` environment variable."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_google_stt_language(language: Language) -> str:

View File

@@ -57,7 +57,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Google AI, you need to `pip install pipecat-ai[google]`. Also, set `GOOGLE_APPLICATION_CREDENTIALS` environment variable."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_google_tts_language(language: Language) -> str:

View File

@@ -35,7 +35,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Google AI, you need to `pip install pipecat-ai[google]`. Also, set `GOOGLE_APPLICATION_CREDENTIALS` environment variable."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -44,7 +44,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error('In order to use Gradium, you need to `pip install "pipecat-ai[gradium]"`.')
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Seconds to wait after a "flushed" message for trailing text tokens to arrive
# before finalizing the transcription.

View File

@@ -33,7 +33,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Gradium, you need to `pip install pipecat-ai[gradium]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
SAMPLE_RATE = 48000

View File

@@ -30,7 +30,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Groq, you need to `pip install pipecat-ai[groq]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Hint set for `output_format`. The values mirror the Literal that
# `groq.resources.audio.speech.AsyncSpeech.create` accepts on its

View File

@@ -46,7 +46,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use HeyGen, you need to `pip install pipecat-ai[heygen]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
HEY_GEN_SAMPLE_RATE = 24000

View File

@@ -38,7 +38,7 @@ try:
except ModuleNotFoundError as e: # pragma: no cover - import-time guidance
logger.error(f"Exception: {e}")
logger.error("In order to use Hume, you need to `pip install pipecat-ai[hume]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
HUME_SAMPLE_RATE = 48_000 # Hume TTS streams at 48 kHz

View File

@@ -68,7 +68,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Inworld Realtime, you need to `pip install pipecat-ai[inworld]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -43,7 +43,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Inworld WebSocket TTS, you need to `pip install websockets`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
from pipecat.frames.frames import (
AggregationType,

View File

@@ -32,7 +32,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Kokoro, you need to `pip install pipecat-ai[kokoro]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
KOKORO_CACHE_DIR = Path(os.path.expanduser("~/.cache/kokoro-onnx"))
KOKORO_MODEL_URL = "https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files-v1.0/kokoro-v1.0.onnx"

View File

@@ -34,7 +34,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use LMNT, you need to `pip install pipecat-ai[lmnt]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_lmnt_language(language: Language) -> str:

View File

@@ -29,7 +29,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use an MCP client, you need to `pip install pipecat-ai[mcp]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
ServerParameters: TypeAlias = StdioServerParameters | SseServerParameters | StreamableHttpParameters

View File

@@ -28,7 +28,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Mem0, you need to `pip install mem0ai`. Also, set the environment variable MEM0_API_KEY."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class Mem0MemoryService(FrameProcessor):

View File

@@ -48,7 +48,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Mistral STT, you need to `pip install pipecat-ai[mistral]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -31,7 +31,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Mistral TTS, you need to `pip install pipecat-ai[mistral]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -34,7 +34,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Moondream, you need to `pip install pipecat-ai[moondream]`.")
raise Exception(f"Missing module(s): {e}")
raise ImportError(f"Missing module(s): {e}") from e
def detect_device():

View File

@@ -41,7 +41,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Neuphonic, you need to `pip install pipecat-ai[neuphonic]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_neuphonic_lang_code(language: Language) -> str:

View File

@@ -46,7 +46,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use NVIDIA Nemotron Speech STT, you need to `pip install pipecat-ai[nvidia]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_nvidia_nemotron_speech_language(language: Language) -> str:

View File

@@ -55,7 +55,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use NVIDIA Nemotron Speech TTS, you need to `pip install pipecat-ai[nvidia]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -71,7 +71,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use OpenAI, you need to `pip install pipecat-ai[openai]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -59,7 +59,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use OpenAI, you need to `pip install pipecat-ai[openai]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# ---------------------------------------------------------------------------

View File

@@ -30,7 +30,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Piper, you need to `pip install pipecat-ai[piper]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -33,7 +33,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Resemble AI, you need to `pip install pipecat-ai[resembleai]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -47,7 +47,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Rime, you need to `pip install pipecat-ai[rime]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_rime_language(language: Language) -> str:

View File

@@ -53,7 +53,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Sarvam, you need to `pip install pipecat-ai[sarvam]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_sarvam_language(language: Language) -> str:

View File

@@ -70,7 +70,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Sarvam, you need to `pip install pipecat-ai[sarvam]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class SarvamTTSModel(StrEnum):

View File

@@ -35,7 +35,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Simli, you need to `pip install pipecat-ai[simli]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -48,7 +48,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Smallest, you need to `pip install pipecat-ai[smallest]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_smallest_stt_language(language: Language) -> str:

View File

@@ -41,7 +41,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Smallest, you need to `pip install pipecat-ai[smallest]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class SmallestTTSModel(StrEnum):

View File

@@ -39,7 +39,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Soniox, you need to `pip install pipecat-ai[soniox]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
KEEPALIVE_MESSAGE = '{"type": "keepalive"}'

View File

@@ -44,7 +44,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Soniox, you need to `pip install pipecat-ai[soniox]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Soniox idle timeout is 20-30s; keepalive cadence must stay well inside it.

View File

@@ -61,7 +61,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Speechmatics, you need to `pip install pipecat-ai[speechmatics]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
load_dotenv()

View File

@@ -32,7 +32,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Speechmatics, you need to `pip install pipecat-ai[speechmatics]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -57,7 +57,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Ultravox, you need to `pip install pipecat-ai[ultravox]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Result shipped as the client_tool_result when we see an async-tool

View File

@@ -33,14 +33,14 @@ if TYPE_CHECKING:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Whisper, you need to `pip install pipecat-ai[whisper]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
try:
import mlx_whisper # noqa: F401
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Whisper, you need to `pip install pipecat-ai[mlx-whisper]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class Model(Enum):

View File

@@ -67,7 +67,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use Grok Realtime, you need to `pip install pipecat-ai[grok]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
@dataclass

View File

@@ -41,7 +41,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error('In order to use xAI STT, you need to `pip install "pipecat-ai[xai]"`.')
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_xai_stt_language(language: Language) -> str:

View File

@@ -46,7 +46,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use XAITTSService, you need to `pip install pipecat-ai[xai]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
def language_to_xai_language(language: Language) -> str:

View File

@@ -75,7 +75,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use the Daily transport, you need to `pip install pipecat-ai[daily]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
VAD_RESET_PERIOD_MS = 2000

View File

@@ -52,7 +52,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use LiveKit, you need to `pip install pipecat-ai[livekit]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# DTMF mapping according to RFC 4733
DTMF_CODE_MAP = {

View File

@@ -28,7 +28,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use local audio, you need to `pip install pipecat-ai[local]`. On MacOS, you also need to `brew install portaudio`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class LocalAudioTransportParams(TransportParams):

View File

@@ -34,14 +34,14 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use local audio, you need to `pip install pipecat-ai[local]`. On MacOS, you also need to `brew install portaudio`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
try:
import tkinter as tk
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("tkinter missing. Try `apt install python3-tk` or `brew install python-tk@3.10`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class TkTransportParams(TransportParams):

View File

@@ -36,7 +36,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use the SmallWebRTC, you need to `pip install pipecat-ai[webrtc]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
# Clamp aiortc's SCTP DATA-chunk payload size so the on-wire UDP packet fits
# inside the smallest-MTU path we're likely to see (IPv6 minimum 1280,

View File

@@ -52,7 +52,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use the SmallWebRTC, you need to `pip install pipecat-ai[webrtc]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
CAM_VIDEO_SOURCE = "camera"
SCREEN_VIDEO_SOURCE = "screenVideo"

View File

@@ -73,7 +73,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use Vonage Video Connector, you need to `pip install pipecat-ai[vonage-video-connector]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class VonageVideoConnectorTransportParams(TransportParams):

View File

@@ -48,7 +48,7 @@ except ModuleNotFoundError as e:
logger.error(
"In order to use FastAPI websockets, you need to `pip install pipecat-ai[websocket]`."
)
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class FastAPIWebsocketParams(TransportParams):

View File

@@ -46,7 +46,7 @@ try:
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error("In order to use websockets, you need to `pip install pipecat-ai[websocket]`.")
raise Exception(f"Missing module: {e}")
raise ImportError(f"Missing module: {e}") from e
class WebsocketServerParams(TransportParams):