transports(websocket): verify websockets module

This commit is contained in:
Aleix Conchillo Flaqué
2024-06-21 08:36:27 -07:00
parent 42c668b7ae
commit 8d867c30c6
2 changed files with 8 additions and 3 deletions

View File

@@ -4,4 +4,4 @@
<Stream url="wss://<your server url>/ws"></Stream> <Stream url="wss://<your server url>/ws"></Stream>
</Connect> </Connect>
<Pause length="40"/> <Pause length="40"/>
</Response> </Response>

View File

@@ -4,11 +4,9 @@
# SPDX-License-Identifier: BSD 2-Clause License # SPDX-License-Identifier: BSD 2-Clause License
# #
import asyncio import asyncio
import io import io
import wave import wave
import websockets
from typing import Awaitable, Callable from typing import Awaitable, Callable
from pydantic.main import BaseModel from pydantic.main import BaseModel
@@ -23,6 +21,13 @@ from pipecat.transports.base_transport import BaseTransport, TransportParams
from loguru import logger from loguru import logger
try:
import websockets
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}")
class WebsocketServerParams(TransportParams): class WebsocketServerParams(TransportParams):
add_wav_header: bool = False add_wav_header: bool = False