fix: filter own key events, fix RoomOptions None, wait for participant
- Skip bot own encryption_keys events in on_unknown handler - Always pass valid RoomOptions to AgentSession.start() - Wait up to 10s for remote participant to connect before starting pipeline Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
20
voice.py
20
voice.py
@@ -214,12 +214,22 @@ class VoiceSession:
|
||||
logger.info("Connected (E2EE=HKDF), remote=%d",
|
||||
len(self.lk_room.remote_participants))
|
||||
|
||||
# Find the remote participant to link to
|
||||
# Find the remote participant, wait up to 10s if not yet connected
|
||||
remote_identity = None
|
||||
for p in self.lk_room.remote_participants.values():
|
||||
remote_identity = p.identity
|
||||
logger.info("Linking to remote participant: %s", remote_identity)
|
||||
break
|
||||
if not remote_identity:
|
||||
logger.info("No remote participant yet, waiting...")
|
||||
for _ in range(100):
|
||||
await asyncio.sleep(0.1)
|
||||
for p in self.lk_room.remote_participants.values():
|
||||
remote_identity = p.identity
|
||||
break
|
||||
if remote_identity:
|
||||
break
|
||||
if remote_identity:
|
||||
logger.info("Linking to remote participant: %s", remote_identity)
|
||||
|
||||
# Voice pipeline — German male voice (Daniel)
|
||||
self._http_session = aiohttp.ClientSession()
|
||||
@@ -242,13 +252,13 @@ class VoiceSession:
|
||||
logger.info("AGENT_SPEECH: %s", msg.text_content)
|
||||
|
||||
agent = Agent(instructions=VOICE_PROMPT)
|
||||
room_opts = room_io.RoomOptions(
|
||||
io_opts = room_io.RoomOptions(
|
||||
participant_identity=remote_identity,
|
||||
) if remote_identity else None
|
||||
) if remote_identity else room_io.RoomOptions()
|
||||
await self.session.start(
|
||||
agent=agent,
|
||||
room=self.lk_room,
|
||||
room_options=room_opts,
|
||||
room_options=io_opts,
|
||||
)
|
||||
logger.info("Voice pipeline started (voice=%s, linked_to=%s)", voice_id, remote_identity)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user