I am following the guide for text transcriptions a...
# agents
e
I am following the guide for text transcriptions and the python SDK for sending text using this room.local_participant.publish_data Now, what happens is that if I send a text input, that immediately gets echoed back in the room as well. For this, I added the filter for role and now I only see agent speech in the chat box, To handle this, I tried to use the user_input_transcribed event and send the text back using the same method above, But unable to figure out why I am not receiving the role, the chat message doesn't get tagged as user but instead just stays empty. One thing I noticed is that the lk-meta-data is missing for the text "Hey, I am good, How are you?" When it was transcribed and sent using the user_input_transcribed event. Also the following message from agent is also not tagged with name anymore just after that as I show in the screenshot below. Can you help with some direction here @refined-appointment-81829, tried a couple of ways and unable to figure this out. Using the below code for sending messages to the topic async def _send_to_chat(payload): await ctx.room.local_participant.publish_data( payload=payload, topic="lk-chat-topic", reliable=True ) @session.on("user_input_transcribed") def on_user_input_transcribed(event: UserInputTranscribedEvent): logger.info(f"User input transcribed: {event.transcript}, " f"language: {event.language}, " f"final: {event.is_final}, " f"speaker id: {event.speaker_id}") if event.is_final: response_payload = json.dumps({ "id": str(uuid.uuid4()), "timestamp": int(time.time() * 1000), "message": event.transcript }) asyncio.create_task(_send_to_chat(response_payload)) @session.on("conversation_item_added") def on_conversation_item_added(event: ConversationItemAddedEvent): logger.info( f"Conversation item added from {event.item.role}: {event.item.text_content}. interrupted: {event.item.interrupted}" ) # Always publish "assistant" items (agent responses) if event.item.role == "assistant": response_payload = json.dumps({ "id": str(uuid.uuid4()), "timestamp": int(time.time() * 1000), "message": event.item.text_content, "role": event.item.role, # "assistant" for TTS }) asyncio.create_task(_send_to_chat(response_payload))
Essentially trying to use both Audio and text inputs
e
let me check again, Thanks @refined-appointment-81829. Agents playground is able to automatically do this but if I use LivekitRoom component, I am facing this issue. Not sure if I have to write some hooks on the frontend to handle this seperately or the component should be enough
Frontend is implemented like this
Copy code
(
  <LiveKitRoom
    token={token}
    serverUrl={NEXT_PUBLIC_LIVEKIT_WS_URL}
    connect
    data-lk-theme="default"
    style={{ height: "80vh" }}
  >
    <VideoConference style={{ height: "100%" }} />
  </LiveKitRoom>
);