transports(websockets): use frame serializers during interruptions

This commit is contained in:
Aleix Conchillo Flaqué
2024-12-02 11:01:55 -08:00
parent 32495ddd0b
commit c2135cbe11
3 changed files with 9 additions and 2 deletions

View File

@@ -22,6 +22,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed a `WebsocketServerTransport` issue that would prevent interruptions with
`TwilioSerializer` from working.
- `DailyTransport.capture_participant_video` now allows capturing user's screen
share by simply passing `video_source="screenVideo"`.

View File

@@ -15,8 +15,6 @@ from pydantic.main import BaseModel
from pipecat.frames.frames import (
AudioRawFrame,
CancelFrame,
EndFrame,
Frame,
InputAudioRawFrame,
StartFrame,

View File

@@ -148,6 +148,7 @@ class WebsocketServerOutputTransport(BaseOutputTransport):
await super().process_frame(frame, direction)
if isinstance(frame, StartInterruptionFrame):
await self._write_frame(frame)
self._next_send_time = 0
async def write_raw_audio_frames(self, frames: bytes):
@@ -189,6 +190,11 @@ class WebsocketServerOutputTransport(BaseOutputTransport):
self._websocket_audio_buffer = bytes()
async def _write_frame(self, frame: Frame):
payload = self._params.serializer.serialize(frame)
if payload and self._websocket:
await self._websocket.send(payload)
class WebsocketServerTransport(BaseTransport):
def __init__(