From ba42cffcc28b670049f08d4f68758e4fa811b730 Mon Sep 17 00:00:00 2001 From: Chad Bailey Date: Fri, 31 May 2024 14:16:53 +0000 Subject: [PATCH] test cleanup --- src/pipecat/frames/frames.py | 2 +- src/pipecat/pipeline/merge_pipeline.py | 5 ++--- src/pipecat/serializers/protobuf_serializer.py | 4 ++-- src/pipecat/transports/services/daily.py | 2 +- tests/test_aggregators.py | 18 +++++++++--------- .../test_protobuf_serializer.py | 0 .../test_websocket_transport.py | 14 +++++++------- 7 files changed, 22 insertions(+), 23 deletions(-) rename tests/{ => to_be_updated}/test_protobuf_serializer.py (100%) rename tests/{ => to_be_updated}/test_websocket_transport.py (91%) diff --git a/src/pipecat/frames/frames.py b/src/pipecat/frames/frames.py index 8eb32664c..5c2c30548 100644 --- a/src/pipecat/frames/frames.py +++ b/src/pipecat/frames/frames.py @@ -307,7 +307,7 @@ class UserStoppedSpeakingFrame(ControlFrame): @dataclass class TTSStartedFrame(ControlFrame): """Used to indicate the beginning of a TTS response. Following - AudioRawFrames are part of the TTS response until an TTSEndFrame. These + AudioRawFrames are part of the TTS response until an TTSStoppedFrame. These frames can be used for aggregating audio frames in a transport to optimize the size of frames sent to the session, without needing to control this in the TTS service. diff --git a/src/pipecat/pipeline/merge_pipeline.py b/src/pipecat/pipeline/merge_pipeline.py index f6f9a5ebd..0043d9e44 100644 --- a/src/pipecat/pipeline/merge_pipeline.py +++ b/src/pipecat/pipeline/merge_pipeline.py @@ -1,5 +1,5 @@ from typing import List -from pipecat.frames.frames import EndFrame, EndPipeFrame +from pipecat.frames.frames import EndFrame from pipecat.pipeline.pipeline import Pipeline @@ -16,8 +16,7 @@ class SequentialMergePipeline(Pipeline): while True: frame = await pipeline.sink.get() if isinstance( - frame, EndFrame) or isinstance( - frame, EndPipeFrame): + frame, EndFrame): break await self.sink.put(frame) diff --git a/src/pipecat/serializers/protobuf_serializer.py b/src/pipecat/serializers/protobuf_serializer.py index e41080607..2bf9899ae 100644 --- a/src/pipecat/serializers/protobuf_serializer.py +++ b/src/pipecat/serializers/protobuf_serializer.py @@ -1,6 +1,6 @@ import dataclasses from typing import Text -from pipecat.frames.frames import AudioFrame, Frame, TextFrame, TranscriptionFrame +from pipecat.frames.frames import AudioRawFrame, Frame, TextFrame, TranscriptionFrame import pipecat.frames.protobufs.frames_pb2 as frame_protos from pipecat.serializers.abstract_frame_serializer import FrameSerializer @@ -8,7 +8,7 @@ from pipecat.serializers.abstract_frame_serializer import FrameSerializer class ProtobufFrameSerializer(FrameSerializer): SERIALIZABLE_TYPES = { TextFrame: "text", - AudioFrame: "audio", + AudioRawFrame: "audio", TranscriptionFrame: "transcription" } diff --git a/src/pipecat/transports/services/daily.py b/src/pipecat/transports/services/daily.py index e4c0a9762..636edf5bb 100644 --- a/src/pipecat/transports/services/daily.py +++ b/src/pipecat/transports/services/daily.py @@ -17,8 +17,8 @@ from functools import partial from typing import Any, Callable, Mapping from daily import ( - CallClient, Daily, + CallClient, EventHandler, VirtualCameraDevice, VirtualMicrophoneDevice, diff --git a/tests/test_aggregators.py b/tests/test_aggregators.py index 5675547e2..9b48e4be8 100644 --- a/tests/test_aggregators.py +++ b/tests/test_aggregators.py @@ -9,9 +9,9 @@ from pipecat.processors.aggregators.gated import GatedAggregator from pipecat.pipeline.parallel_pipeline import ParallelPipeline from pipecat.frames.frames import ( - AudioFrame, + AudioRawFrame, EndFrame, - ImageFrame, + ImageRawFrame, LLMResponseEndFrame, LLMResponseStartFrame, Frame, @@ -45,26 +45,26 @@ class TestDailyFrameAggregators(unittest.IsolatedAsyncioTestCase): async def test_gated_accumulator(self): gated_aggregator = GatedAggregator( gate_open_fn=lambda frame: isinstance( - frame, ImageFrame), gate_close_fn=lambda frame: isinstance( + frame, ImageRawFrame), gate_close_fn=lambda frame: isinstance( frame, LLMResponseStartFrame), start_open=False, ) frames = [ LLMResponseStartFrame(), TextFrame("Hello, "), TextFrame("world."), - AudioFrame(b"hello"), - ImageFrame(b"image", (0, 0)), - AudioFrame(b"world"), + AudioRawFrame(b"hello", 1, 1), + ImageRawFrame(b"image", (0, 0)), + AudioRawFrame(b"world", 1, 1), LLMResponseEndFrame(), ] expected_output_frames = [ - ImageFrame(b"image", (0, 0)), + ImageRawFrame(b"image", (0, 0)), LLMResponseStartFrame(), TextFrame("Hello, "), TextFrame("world."), - AudioFrame(b"hello"), - AudioFrame(b"world"), + AudioRawFrame(b"hello", 1, 1), + AudioRawFrame(b"world", 1, 1), LLMResponseEndFrame(), ] for frame in frames: diff --git a/tests/test_protobuf_serializer.py b/tests/to_be_updated/test_protobuf_serializer.py similarity index 100% rename from tests/test_protobuf_serializer.py rename to tests/to_be_updated/test_protobuf_serializer.py diff --git a/tests/test_websocket_transport.py b/tests/to_be_updated/test_websocket_transport.py similarity index 91% rename from tests/test_websocket_transport.py rename to tests/to_be_updated/test_websocket_transport.py index 56c5df16c..59b42432d 100644 --- a/tests/test_websocket_transport.py +++ b/tests/to_be_updated/test_websocket_transport.py @@ -2,7 +2,7 @@ import asyncio import unittest from unittest.mock import AsyncMock, patch, Mock -from pipecat.frames.frames import AudioFrame, EndFrame, TextFrame, TTSEndFrame, TTSStartFrame +from pipecat.frames.frames import AudioRawFrame, EndFrame, TextFrame, TTSStoppedFrame, TTSStartedFrame from pipecat.pipeline.pipeline import Pipeline from pipecat.transports.websocket_transport import WebSocketFrameProcessor, WebsocketTransport @@ -52,10 +52,10 @@ class TestWebSocketTransportService(unittest.IsolatedAsyncioTestCase): processor = WebSocketFrameProcessor(audio_frame_size=4) source_frames = [ - TTSStartFrame(), - AudioFrame(b"1234"), - AudioFrame(b"5678"), - TTSEndFrame(), + TTSStartedFrame(), + AudioRawFrame(b"1234", 1, 1), + AudioRawFrame(b"5678", 1, 1), + TTSStoppedFrame(), TextFrame("hello world") ] @@ -65,9 +65,9 @@ class TestWebSocketTransportService(unittest.IsolatedAsyncioTestCase): frames.append(output_frame) self.assertEqual(len(frames), 3) - self.assertIsInstance(frames[0], AudioFrame) + self.assertIsInstance(frames[0], AudioRawFrame) self.assertEqual(frames[0].data, b"1234") - self.assertIsInstance(frames[1], AudioFrame) + self.assertIsInstance(frames[1], AudioRawFrame) self.assertEqual(frames[1].data, b"5678") self.assertIsInstance(frames[2], TextFrame) self.assertEqual(frames[2].text, "hello world")