From f385cc04608a099d3e7131340202db0f1c8271f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 14 Apr 2025 13:08:27 -0700 Subject: [PATCH] pyproject: add websockets as google dependency --- pyproject.toml | 2 +- src/pipecat/services/gemini_multimodal_live/gemini.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8b7c8546a..cb0cd3520 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ fal = [ "fal-client~=0.5.9" ] fireworks = [] fish = [ "ormsgpack~=1.7.0", "websockets~=13.1" ] gladia = [ "websockets~=13.1" ] -google = [ "google-cloud-speech~=2.31.1", "google-cloud-texttospeech~=2.25.1", "google-genai~=1.7.0", "google-generativeai~=0.8.4" ] +google = [ "google-cloud-speech~=2.31.1", "google-cloud-texttospeech~=2.25.1", "google-genai~=1.7.0", "google-generativeai~=0.8.4", "websockets~=13.1" ] grok = [] groq = [ "groq~=0.20.0" ] gstreamer = [ "pygobject~=3.50.0" ] diff --git a/src/pipecat/services/gemini_multimodal_live/gemini.py b/src/pipecat/services/gemini_multimodal_live/gemini.py index f89e97bdb..d953e5065 100644 --- a/src/pipecat/services/gemini_multimodal_live/gemini.py +++ b/src/pipecat/services/gemini_multimodal_live/gemini.py @@ -10,9 +10,8 @@ import json import time from dataclasses import dataclass from enum import Enum -from typing import Any, Dict, List, Mapping, Optional, Union +from typing import Any, Dict, List, Optional, Union -import websockets from loguru import logger from pydantic import BaseModel, Field @@ -65,6 +64,13 @@ from pipecat.utils.time import time_now_iso8601 from . import events from .audio_transcriber import AudioTranscriber +try: + import websockets +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}") + def language_to_gemini_language(language: Language) -> Optional[str]: """Maps a Language enum value to a Gemini Live supported language code.