Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] make text messaging work in livekit #604

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 8 additions & 0 deletions vocode/streaming/livekit/livekit_conversation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import asyncio
import json

from livekit import rtc
from livekit.rtc.chat import _CHAT_TOPIC
from loguru import logger

from vocode.streaming.livekit.livekit_events_manager import LiveKitEventsManager
Expand All @@ -25,11 +27,17 @@ async def start_room(self, room: rtc.Room):
self.room = room
room.on("track_subscribed", self._on_track_subscribed)
room.on("track_unsubscribed", self._on_track_unsubscribed)
room.on("data_received", self._on_data_received)

await self.output_device.initialize_source(room)

await super().start()

def _on_data_received(self, packet: rtc.DataPacket):
if packet.topic == _CHAT_TOPIC:
chat = json.loads(packet.data.decode("utf-8"))
self.receive_message(chat["message"])

def _on_track_subscribed(
self,
track: rtc.Track,
Expand Down
Loading