Skip to content

Commit

Permalink
initial text message wiring
Browse files Browse the repository at this point in the history
  • Loading branch information
ajar98 committed Jul 4, 2024
1 parent 918412c commit ef1a307
Showing 1 changed file with 8 additions and 0 deletions.
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

0 comments on commit ef1a307

Please sign in to comment.