Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 16 additions & 26 deletions src/pipecat_getstream/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,22 @@

import asyncio
import time
import warnings
from dataclasses import dataclass
from fractions import Fraction
from typing import Any, Callable, Coroutine, Dict, List, Optional

import av
import numpy as np
from aiortc import MediaStreamTrack
from getstream import AsyncStream
from getstream.models import UserRequest
from getstream.video import rtc
from getstream.video.async_call import Call
from getstream.video.rtc import AudioStreamTrack, PcmData
from getstream.video.rtc.connection_manager import ConnectionManager
from getstream.video.rtc.pb.stream.video.sfu.models.models_pb2 import TrackType
from getstream.video.rtc.tracks import SubscriptionConfig, TrackSubscriptionConfig
from loguru import logger
from pipecat.audio.utils import create_stream_resampler
from pipecat.frames.frames import (
Expand Down Expand Up @@ -41,32 +52,11 @@
"BGR": "bgr24",
"L": "gray",
}

try:
import warnings

import av
from aiortc import MediaStreamTrack
from getstream import AsyncStream
from getstream.models import UserRequest
from getstream.video import rtc
from getstream.video.async_call import Call
from getstream.video.rtc import AudioStreamTrack, PcmData
from getstream.video.rtc.connection_manager import ConnectionManager
from getstream.video.rtc.pb.stream.video.sfu.models.models_pb2 import TrackType
from getstream.video.rtc.tracks import SubscriptionConfig, TrackSubscriptionConfig

# Suppress dataclasses_json missing value RuntimeWarnings.
# They pollute the output and cannot be fixed by the users.
warnings.filterwarnings(
"ignore", category=RuntimeWarning, module="dataclasses_json.core"
)
except ModuleNotFoundError as _e:
logger.error(f"Exception: {_e}")
logger.error(
"In order to use Stream Video, you need to `pip install pipecat-ai[getstream]`."
)
raise Exception(f"Missing module: {_e}")
# Suppress dataclasses_json missing value RuntimeWarnings.
# They pollute the output and cannot be fixed by the users.
warnings.filterwarnings(
"ignore", category=RuntimeWarning, module="dataclasses_json.core"
)


@dataclass
Expand Down
13 changes: 2 additions & 11 deletions src/pipecat_getstream/utils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
from loguru import logger

try:
from getstream import AsyncStream
from getstream.models import UserRequest
except ModuleNotFoundError as e:
logger.error(f"Exception: {e}")
logger.error(
"In order to use Stream Video, you need to `pip install pipecat-ai[getstream]`."
)
raise Exception(f"Missing module: {e}")
from getstream import AsyncStream
from getstream.models import UserRequest


class GetstreamRESTHelper:
Expand Down