forked from pipecat-ai/pipecat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into pr/add-lmnt
- Loading branch information
Showing
8 changed files
with
76 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
beautifulsoup4==4.12.2 | ||
PyPDF2==3.0.1 | ||
beautifulsoup4==4.12.3 | ||
pypdf==4.3.1 | ||
tiktoken==0.7.0 | ||
pipecat-ai[daily,cartesia,openai,silero]==0.0.39 | ||
pipecat-ai[daily,cartesia,openai,silero]==0.0.40 | ||
python-dotenv==1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# Copyright (c) 2024, Daily | ||
# | ||
# SPDX-License-Identifier: BSD 2-Clause License | ||
# | ||
|
||
import ctypes | ||
import pickle | ||
|
||
from pipecat.frames.frames import AudioRawFrame, Frame | ||
from pipecat.serializers.base_serializer import FrameSerializer | ||
|
||
from loguru import logger | ||
|
||
try: | ||
from livekit.rtc import AudioFrame | ||
except ModuleNotFoundError as e: | ||
logger.error(f"Exception: {e}") | ||
logger.error( | ||
"In order to use LiveKit, you need to `pip install pipecat-ai[livekit]`.") | ||
raise Exception(f"Missing module: {e}") | ||
|
||
|
||
class LivekitFrameSerializer(FrameSerializer): | ||
SERIALIZABLE_TYPES = { | ||
AudioRawFrame: "audio", | ||
} | ||
|
||
def serialize(self, frame: Frame) -> str | bytes | None: | ||
if not isinstance(frame, AudioRawFrame): | ||
return None | ||
audio_frame = AudioFrame( | ||
data=frame.audio, | ||
sample_rate=frame.sample_rate, | ||
num_channels=frame.num_channels, | ||
samples_per_channel=len(frame.audio) // ctypes.sizeof(ctypes.c_int16), | ||
) | ||
return pickle.dumps(audio_frame) | ||
|
||
def deserialize(self, data: str | bytes) -> Frame | None: | ||
audio_frame: AudioFrame = pickle.loads(data)['frame'] | ||
return AudioRawFrame( | ||
audio=bytes(audio_frame.data), | ||
sample_rate=audio_frame.sample_rate, | ||
num_channels=audio_frame.num_channels, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters