Repository navigation
Conversation
|
@tinalenguyen this one follows up #8535: an avatar drawn in the visitor's browser, with no avatar participant. Happy to change anything to fit your conventions. |
f1f2fc5 to
294a6cd
Compare
tinalenguyen
left a comment
There was a problem hiding this comment.
hi, thanks for the PR! since the avatar is rendered on the visitor's page, the agent side here comes down to agent_session.output.audio = DataStreamAudioOutput(room, destination_identity=visitor_identity, wait_playback_start=True), which users can already do with core and no MeshLite-specific call. the rest of the plugin works around the base AvatarSession assuming an avatar participant (aclose() re-implementing the base cleanup, reaching into output._start_atask, avatar_identity returning the visitor). is there something meshlite-specific the agent side needs? if not, maybe the snippet above could live in meshlite's own livekit guide instead of a separate plugin here, since any client-rendered avatar would need the same few lines
MeshLite draws the avatar in the visitor's browser, so the plugin adds no participant and no video track: it routes the agent's voice to the visitor's page over the avatar data-stream protocol. It extends the base AvatarSession but never removes the visitor from the room on close. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RoomIO wraps the avatar output in a TranscriptSynchronizer, so comparing session.output.audio with our output missed it and the agent kept speaking to the visitor after aclose(). Follow next_in_chain instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review feedback: the agent side only routed audio, which core already does with DataStreamAudioOutput, and worked around the base AvatarSession. The agent now does the MeshLite-specific step itself, like the other avatar plugins: with MESHLITE_API_KEY it creates the session on the MeshLite API and hands the single-use token to the visitor page only, through the meshlite.session_token RPC. It also tells the page the language of each reply (meshlite.set_language) so the lip model follows the conversation. The workarounds are gone: no private attributes, aclose() defers to the base class, and the output is installed with replace_audio_tail(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
294a6cd to
44459c0
Compare
|
Thanks Tina, fair points. I pushed an update. The agent side now does the MeshLite work, like the other avatar plugins. It also keeps the lips in the right language. At the end of each reply it tells the page the reply language through the The workarounds you flagged are gone: no private attributes, |
There was a problem hiding this comment.
Devin Review found 2 new potential issues.
3 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| room, session = self._room, self._agent_session | ||
| if room is not None and self._started: | ||
| room.local_participant.unregister_rpc_method(SESSION_TOKEN_RPC) | ||
| if session is not None and self._follow_language and self._started: | ||
| session.off("conversation_item_added", self._on_reply_language) | ||
| for task in list(self._tasks): | ||
| task.cancel() | ||
| await super().aclose() |
There was a problem hiding this comment.
🟡 Avatar audio survives session close
aclose() leaves the MeshLite audio sink installed when the agent keeps running. Base cleanup never restores the audio route, so later replies still stream to the closed avatar.
Learn more
MeshLite installs its output with replace_audio_tail, which can put the sink under existing recording or transcription wrappers. Avatar sessions can be closed independently of the running agent, as the avatar switching example shows. The base cleanup releases listeners and the join task but does not touch the output chain.
Example: An app ends the avatar portion of a call, awaits avatar.aclose(), and has the agent say a final message. The message still goes to MeshLite instead of the replacement route or no output.
Recommended fix: On close, remove only the audio route still owned by this MeshLite instance. Restore the displaced sink where applicable, preserve wrappers when swapping the tail, and leave a sink installed by the caller after start untouched. Cover both wrapped and unwrapped routes with a close test.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
This matches the other avatar plugins here (Anam, Tavus, Simli, Bey, LiveAvatar): closing the avatar session does not change the agent session's audio output. We removed our own detach code after the review asked us to rely on the base cleanup. Happy to add it back if you prefer.
Devin read the old line as attach after connect, which would drop the first words. The SDK receives the voice from the first word only when the room is attached before it connects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keeps LiveKit's new dependency versions and adds the meshlite extra to them, so the pull request merges cleanly again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Adds
livekit-plugins-meshlite, a plugin that gives a LiveKit voice agent a MeshLite avatar: a lip-synced face rendered in the visitor's own browser by the MeshLite web SDK. The agent keeps its own STT, LLM and TTS (or realtime model). Follows up #8535.It works differently from the other avatar plugins: there is no avatar participant and no video track.
meshlite.AvatarSession.start()routes the session audio to the visitor's page with the standardDataStreamAudioOutput(lk.audio_stream,lk.clear_buffer,lk.playback_started,lk.playback_finished), and the page plays the voice in sync with the face. Interruptions and the played-back position work as with the other avatar plugins. Nothing runs server-side per conversation.meshlite.AvatarSessionextendslivekit.agents.voice.avatar.AvatarSession.avatar_identityis the visitor's identity, since the avatar lives in the visitor's page. For that reasonaclose()overrides the base class: it restores the audio output and never removes a participant from the room.wait_for_join()returns once the visitor is in the room (no video track to wait for), and emits the usualAvatarMetrics.Known limit: room recordings (egress) do not contain the agent's voice, because no audio track is published.
What's included
livekit-plugins/livekit-plugins-meshlite/, the plugin packageuvworkspace member and as alivekit-agents[meshlite]extra, withuv.lockregeneratedtests/test_plugin_meshlite.py, unit tests in a faked room (pytest.mark.unit,pytest.mark.plugin("meshlite"))Test plan
ruff check/ruff format --checkmypy -p livekit.plugins.meshlitepytest tests/test_plugin_meshlite.py --unit(16 passed)This code was first published under Apache-2.0 at meshlite-avatar/livekit-plugins-meshlite (on PyPI as 0.1.0). We own the
livekit-plugins-meshlitename on PyPI and will set up publishing with you before the first release from this repo.🤖 Generated with Claude Code