livekit-plugins-facemode 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ Copyright © 2026 InfinityLevel OPC Private Limited
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: livekit-plugins-facemode
3
+ Version: 0.1.0
4
+ Summary: FaceMode avatar integration for LiveKit Agents
5
+ License-Expression: Apache-2.0
6
+ Classifier: Programming Language :: Python :: 3
7
+ Requires-Python: >=3.13
8
+ License-File: LICENSE
9
+ Requires-Dist: aiohttp<4,>=3.10
10
+ Requires-Dist: livekit<2,>=1.1
11
+ Requires-Dist: livekit-agents<2,>=1.7
12
+ Requires-Dist: websockets<17,>=14
13
+ Dynamic: license-file
@@ -0,0 +1,73 @@
1
+ # livekit-plugins-facemode
2
+
3
+ FaceMode avatar output for LiveKit Agents Python applications.
4
+
5
+ ## Install
6
+
7
+ ```powershell
8
+ pip install livekit-plugins-facemode
9
+ ```
10
+
11
+ From this repository:
12
+
13
+ ```powershell
14
+ pip install .
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ The host application supplies a server-side LiveKit room object. The room token
20
+ must grant the FaceMode worker permission to join, publish, and subscribe in the
21
+ customer room. Keep the token on the server and never log it or expose it to a
22
+ browser client.
23
+
24
+ ```python
25
+ import os
26
+
27
+ from livekit.agents import Agent, AgentSession, room_io
28
+ from livekit_plugins_facemode import AvatarSession
29
+
30
+ avatar = AvatarSession(
31
+ api_key=os.environ["FACEMODE_API_KEY"],
32
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
33
+ )
34
+
35
+ await ctx.connect()
36
+ await avatar.start(
37
+ agent_session,
38
+ ctx.room,
39
+ room={
40
+ "type": "livekit",
41
+ "url": os.environ["LIVEKIT_URL"],
42
+ "token": os.environ["LIVEKIT_TOKEN"],
43
+ },
44
+ )
45
+ await agent_session.start(
46
+ agent=Agent(instructions="You are a helpful assistant."),
47
+ room=ctx.room,
48
+ room_options=room_io.RoomOptions(audio_output=False),
49
+ )
50
+ await avatar.wait_for_join()
51
+ ```
52
+
53
+ `AvatarSession.start()` creates a FaceMode session with the room object. The create response normally returns `ready: true` with the ingestion `url` and a one-time `wsToken` (about 15 minute expiry), so no polling happens in the common path. If worker assignment is still pending, the plugin polls the session endpoint with bounded backoff for up to 240 seconds and stops immediately on `FAILED`/`ENDED` worker states. The initial response's room credentials remain in memory and are not expected in the polling response.
54
+
55
+ The ingestion WebSocket handshake uses the `Sec-WebSocket-Protocol` subprotocol `facemode.<wsToken>` (the older `aivatar.` prefix is rejected) with a 240 second open timeout. When the backend returns optional `ingestion.headers`, the plugin forwards them during the handshake. It disables compression and native WebSocket keepalives in favor of the canonical application `ping`/`pong` messages after negotiation.
56
+
57
+ Pass `input_provider` (one of `deepgram`, `gemini`, `gnani`, `elevenlabs`, `openai`, `cartesia`, `sarvam`, `custom`) to `AvatarSession` when the session should pin a specific upstream input provider; it is omitted from the request otherwise.
58
+
59
+ If the WebSocket transport drops after the protocol has started, the plugin auto-reconnects in the background: it POSTs the session reconnect endpoint for a fresh one-time `wsToken` (a consumed token is never reused), opens a new socket with `facemode.<newToken>`, re-sends the canonical `start` message, and waits for `started` before resuming. Outgoing control `seq` numbers stay monotonic across the reconnect and buffered audio is not replayed. Reconnect is bounded to 2 attempts with backoff and is single-flight; exhaustion surfaces a typed `FaceModeNotReadyError`/`FaceModeAPIError`. Intentional `stop()`, a canonical `ended`, fatal protocol errors, and drops before the first negotiation do not reconnect.
60
+
61
+ Every TTS frame is sent as canonical PCM audio. The plugin locks sample rate and channel count at protocol negotiation and rejects a format change or unaligned 16-bit PCM afterward. `cancel_utterance` is sent when LiveKit interrupts the audio output. Graceful close sends `end_session` and waits briefly for canonical `ended`; `ended` is a protocol acknowledgement, not backend cleanup confirmation.
62
+
63
+ ## Token grants
64
+
65
+ The `room.token` value must allow the worker to join the customer room and
66
+ publish its avatar audio/video tracks. If the token uses a fixed participant
67
+ identity, use `avatar_participant_identity` and make the room policy allow that
68
+ identity. The worker does not create or replace the customer LiveKit room.
69
+
70
+ ## API URL
71
+
72
+ The default API URL is `https://api.facemode.io/api`. Set `api_url` for a
73
+ self-hosted or local backend.
@@ -0,0 +1,17 @@
1
+ from .avatar import AvatarSession
2
+ from .exceptions import FaceModeAPIError, FaceModeError, FaceModeNotReadyError, FaceModeProtocolError
3
+ from .models import IngestionDetails, LiveKitRoom, SessionDetails, SessionRequest
4
+ from .version import __version__
5
+
6
+ __all__ = [
7
+ "AvatarSession",
8
+ "FaceModeAPIError",
9
+ "FaceModeError",
10
+ "FaceModeNotReadyError",
11
+ "FaceModeProtocolError",
12
+ "IngestionDetails",
13
+ "LiveKitRoom",
14
+ "SessionDetails",
15
+ "SessionRequest",
16
+ "__version__",
17
+ ]