From 4bab20643b78376b06c34697fc225b958101cf1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Wed, 29 May 2024 16:20:04 -0700 Subject: [PATCH] added sample_rate and num_channels to protobuf AudioRawFrame --- examples/foundational/websocket-server/frames.proto | 2 ++ examples/foundational/websocket-server/server.py | 1 - src/pipecat/frames/frames.proto | 2 ++ src/pipecat/frames/protobufs/frames_pb2.py | 12 ++++++------ src/pipecat/serializers/protobuf.py | 1 + 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/examples/foundational/websocket-server/frames.proto b/examples/foundational/websocket-server/frames.proto index 69ac1d460..b6ff1a4d3 100644 --- a/examples/foundational/websocket-server/frames.proto +++ b/examples/foundational/websocket-server/frames.proto @@ -18,6 +18,8 @@ message TextFrame { message AudioRawFrame { bytes audio = 1; + uint32 sample_rate = 2; + uint32 num_channels = 3; } message TranscriptionFrame { diff --git a/examples/foundational/websocket-server/server.py b/examples/foundational/websocket-server/server.py index bf75b7461..7deef7572 100644 --- a/examples/foundational/websocket-server/server.py +++ b/examples/foundational/websocket-server/server.py @@ -54,7 +54,6 @@ async def main(): @transport.event_handler("on_client_connected") async def on_client_connected(transport, client): - print("AAAAAAAA") await task.queue_frame(TextFrame("Hello there!")) runner = PipelineRunner() diff --git a/src/pipecat/frames/frames.proto b/src/pipecat/frames/frames.proto index 69ac1d460..b6ff1a4d3 100644 --- a/src/pipecat/frames/frames.proto +++ b/src/pipecat/frames/frames.proto @@ -18,6 +18,8 @@ message TextFrame { message AudioRawFrame { bytes audio = 1; + uint32 sample_rate = 2; + uint32 num_channels = 3; } message TranscriptionFrame { diff --git a/src/pipecat/frames/protobufs/frames_pb2.py b/src/pipecat/frames/protobufs/frames_pb2.py index 5df1c34a2..32e1c3372 100644 --- a/src/pipecat/frames/protobufs/frames_pb2.py +++ b/src/pipecat/frames/protobufs/frames_pb2.py @@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default() -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x66rames.proto\x12\x07pipecat\"\x19\n\tTextFrame\x12\x0c\n\x04text\x18\x01 \x01(\t\"\x1e\n\rAudioRawFrame\x12\r\n\x05\x61udio\x18\x01 \x01(\x0c\"F\n\x12TranscriptionFrame\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0f\n\x07user_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\t\"\x93\x01\n\x05\x46rame\x12\"\n\x04text\x18\x01 \x01(\x0b\x32\x12.pipecat.TextFrameH\x00\x12\'\n\x05\x61udio\x18\x02 \x01(\x0b\x32\x16.pipecat.AudioRawFrameH\x00\x12\x34\n\rtranscription\x18\x03 \x01(\x0b\x32\x1b.pipecat.TranscriptionFrameH\x00\x42\x07\n\x05\x66rameb\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0c\x66rames.proto\x12\x07pipecat\"\x19\n\tTextFrame\x12\x0c\n\x04text\x18\x01 \x01(\t\"I\n\rAudioRawFrame\x12\r\n\x05\x61udio\x18\x01 \x01(\x0c\x12\x13\n\x0bsample_rate\x18\x02 \x01(\r\x12\x14\n\x0cnum_channels\x18\x03 \x01(\r\"F\n\x12TranscriptionFrame\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0f\n\x07user_id\x18\x02 \x01(\t\x12\x11\n\ttimestamp\x18\x03 \x01(\t\"\x93\x01\n\x05\x46rame\x12\"\n\x04text\x18\x01 \x01(\x0b\x32\x12.pipecat.TextFrameH\x00\x12\'\n\x05\x61udio\x18\x02 \x01(\x0b\x32\x16.pipecat.AudioRawFrameH\x00\x12\x34\n\rtranscription\x18\x03 \x01(\x0b\x32\x1b.pipecat.TranscriptionFrameH\x00\x42\x07\n\x05\x66rameb\x06proto3') _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) @@ -24,9 +24,9 @@ if _descriptor._USE_C_DESCRIPTORS == False: _globals['_TEXTFRAME']._serialized_start=25 _globals['_TEXTFRAME']._serialized_end=50 _globals['_AUDIORAWFRAME']._serialized_start=52 - _globals['_AUDIORAWFRAME']._serialized_end=82 - _globals['_TRANSCRIPTIONFRAME']._serialized_start=84 - _globals['_TRANSCRIPTIONFRAME']._serialized_end=154 - _globals['_FRAME']._serialized_start=157 - _globals['_FRAME']._serialized_end=304 + _globals['_AUDIORAWFRAME']._serialized_end=125 + _globals['_TRANSCRIPTIONFRAME']._serialized_start=127 + _globals['_TRANSCRIPTIONFRAME']._serialized_end=197 + _globals['_FRAME']._serialized_start=200 + _globals['_FRAME']._serialized_end=347 # @@protoc_insertion_point(module_scope) diff --git a/src/pipecat/serializers/protobuf.py b/src/pipecat/serializers/protobuf.py index 24c484b7c..515a653e6 100644 --- a/src/pipecat/serializers/protobuf.py +++ b/src/pipecat/serializers/protobuf.py @@ -7,6 +7,7 @@ import dataclasses import pipecat.frames.protobufs.frames_pb2 as frame_protos + from pipecat.frames.frames import AudioRawFrame, Frame, TextFrame, TranscriptionFrame from pipecat.serializers.base_serializer import FrameSerializer