pipecat-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,257 @@
1
+ Metadata-Version: 2.4
2
+ Name: pipecat-facemode
3
+ Version: 0.1.0
4
+ Summary: FaceMode avatar integration for Pipecat
5
+ License-Expression: Apache-2.0
6
+ Classifier: Programming Language :: Python :: 3
7
+ Requires-Python: >=3.13
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: pipecat-ai<2,>=1.7
11
+ Requires-Dist: livekit<2,>=1.1
12
+ Requires-Dist: aiohttp<4,>=3.10
13
+ Requires-Dist: websockets<17,>=14
14
+ Requires-Dist: numpy<3,>=2
15
+ Dynamic: license-file
16
+
17
+ # pipecat-facemode
18
+
19
+ FaceMode avatar output for Pipecat pipelines. The integration taps
20
+ `TTSAudioRawFrame`, sends canonical 16-bit PCM to FaceMode, and converts the
21
+ avatar's LiveKit audio and video tracks back into Pipecat output frames.
22
+
23
+ The package is intentionally a small `FrameProcessor`. It does not replace a
24
+ Pipecat transport. Place it after a TTS service and before the output transport:
25
+
26
+ ```text
27
+ transport input -> STT -> LLM -> TTS -> FaceModeVideoService -> transport output
28
+ ```
29
+
30
+ By default, source `TTSAudioRawFrame` objects are consumed. This prevents the
31
+ source TTS audio and the avatar's returned audio from being played twice. Set
32
+ `forward_tts_audio=True` only when the pipeline intentionally needs both.
33
+
34
+ ## Install
35
+
36
+ ```powershell
37
+ pip install pipecat-facemode
38
+ ```
39
+
40
+ From this directory:
41
+
42
+ ```powershell
43
+ pip install .
44
+ ```
45
+
46
+ The package supports Pipecat 1.7 through the current 1.x line, LiveKit RTC 1.x, aiohttp 3.x, websockets 14 through 16, and NumPy 2.x.
47
+
48
+ ## Basic usage
49
+
50
+ `room.token` is the server-side worker token sent to FaceMode. The separate
51
+ `livekit_subscriber_token` is used by this Pipecat process to subscribe to the
52
+ room. Use separate participant identities and tokens in production.
53
+
54
+ ```python
55
+ import os
56
+
57
+ from pipecat.pipeline.pipeline import Pipeline
58
+ from pipecat.services.cartesia.tts import CartesiaTTSService
59
+ from pipecat_facemode import FaceModeVideoService
60
+
61
+
62
+ tts = CartesiaTTSService(
63
+ api_key=os.environ["CARTESIA_API_KEY"],
64
+ settings=CartesiaTTSService.Settings(
65
+ voice="71a7ad14-091c-4e8e-a314-022ece01c121",
66
+ ),
67
+ )
68
+
69
+ facemode = FaceModeVideoService(
70
+ api_key=os.environ["FACEMODE_API_KEY"],
71
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
72
+ room={
73
+ "type": "livekit",
74
+ "url": os.environ["LIVEKIT_URL"],
75
+ "token": os.environ["LIVEKIT_WORKER_TOKEN"],
76
+ },
77
+ livekit_subscriber_token=os.environ["LIVEKIT_SUBSCRIBER_TOKEN"],
78
+ room_name=os.environ["LIVEKIT_ROOM_NAME"],
79
+ # Optional speech input provider persisted by the backend for the session:
80
+ # deepgram, gemini, gnani, elevenlabs, openai, cartesia, sarvam, or custom.
81
+ input_provider=os.environ.get("FACEMODE_INPUT_PROVIDER") or None,
82
+ )
83
+
84
+ pipeline = Pipeline([
85
+ transport.input(),
86
+ tts,
87
+ facemode,
88
+ transport.output(),
89
+ ])
90
+ ```
91
+
92
+ See [`examples/basic_pipeline.py`](examples/basic_pipeline.py) for a complete
93
+ pipeline using Pipecat's LiveKit transport. The same-room example disables the
94
+ transport's audio and video outputs because the FaceMode worker already publishes
95
+ both avatar tracks directly into that LiveKit room. It also uses distinct tokens
96
+ for the FaceMode worker, Pipecat subscriber, Pipecat transport, and viewer.
97
+
98
+ ## FaceMode session and WebSocket protocol
99
+
100
+ On `StartFrame`, the service:
101
+
102
+ 1. Connects to the supplied LiveKit room with `livekit-rtc` and enables automatic
103
+ track subscription.
104
+ 2. Calls `POST {api_url}/sessions` with the room object (and `inputProvider`
105
+ when `input_provider` is configured). The request never sends
106
+ `waitForIngestion`; current backends reject it as an unknown field:
107
+
108
+ ```json
109
+ {
110
+ "avatarId": "avatar-id",
111
+ "inputProvider": "deepgram",
112
+ "room": {
113
+ "type": "livekit",
114
+ "url": "wss://project.livekit.cloud",
115
+ "token": "server-side-token"
116
+ }
117
+ }
118
+ ```
119
+
120
+ A `201` response returns `ingestion.ready: true` with the worker WebSocket
121
+ `url` and a one-time `wsToken` immediately.
122
+
123
+ 3. When the response has `ingestion.ready: false`, polls `GET {api_url}/sessions/{id}` using bounded backoff for up to 240 seconds until ready WebSocket credentials are available; `FAILED` or `ENDED` worker states stop the wait immediately. Room credentials from the initial response remain in memory and are not expected in the status response.
124
+ 4. Opens the returned WebSocket with the `facemode.<ws-token>` subprotocol (the `aivatar.` prefix is rejected by current backends), compression disabled, native keepalives disabled, a 240-second open timeout, and optional backend-provided `ingestion.headers` forwarded unchanged. This package requires `websockets>=14`, so it uses the `additional_headers` API and never falls back to an unaffinitized connection.
125
+ 5. Starts the receive task, sends canonical `start` from the pipeline `StartFrame`, and waits for a validated `started` response.
126
+ 6. Starts application keepalives only after negotiation succeeds, preserving the protocol requirement that `start` is the first application message.
127
+
128
+ Call `await service.wait_for_avatar()` when an application needs to wait for
129
+ FaceMode's `audio_ready` event or the first LiveKit video frame before announcing
130
+ that avatar media is available.
131
+
132
+ The canonical protocol messages are used as follows:
133
+
134
+ - `start` negotiates `audio_encoding: pcm_s16le`, sample rate, and channel count.
135
+ - `start_utterance` precedes the first binary audio chunk.
136
+ - `TTSAudioRawFrame.audio` is sent as binary little-endian signed 16-bit PCM,
137
+ with no JSON or base64 wrapper.
138
+ - `end_utterance` follows a TTS stop frame or a short idle period.
139
+ - `cancel_utterance` is sent for `StartInterruptionFrame`.
140
+ - `ping` is sent periodically while the session is alive.
141
+ - `end_session` is sent during graceful `EndFrame` or pipeline cleanup.
142
+
143
+ ## Automatic reconnect
144
+
145
+ If the canonical WebSocket drops after a session was fully started, the service
146
+ reconnects without caller-visible pipeline failure:
147
+
148
+ 1. It calls `POST {api_url}/sessions/{id}/reconnect` with the original `room`
149
+ object (plus the persisted `inputProvider` when configured). Every response
150
+ mints a fresh one-time `wsToken`; tokens are never reused.
151
+ 2. It opens a new socket with the `facemode.<new-token>` subprotocol, resends
152
+ the same `start` negotiation, and waits for `started` before audio resumes.
153
+ 3. At most 2 reconnect attempts run with bounded backoff. Recovery is
154
+ single-flight, so simultaneous close/error notifications share one attempt.
155
+
156
+ Sequence numbers keep increasing across reconnects, an explicitly open
157
+ utterance is re-declared on the new socket, and already-sent audio is never
158
+ replayed. Sends that arrive during the gap wait for the new socket instead of
159
+ failing. No reconnect is attempted on intentional shutdown (`EndFrame`,
160
+ `CancelFrame`, `stop`, `cleanup`), on server-terminal states (`session_ending`,
161
+ `ended`, fatal `error` messages), or before the session is fully started. When
162
+ the reconnect budget is exhausted, the failure surfaces as a
163
+ `FaceModeProtocolError` that never contains token or key material.
164
+
165
+ The service calls `super().__init__()` and `super().process_frame(...)`, and
166
+ forwards non-consumed frames with their original `FrameDirection`. Lifecycle and
167
+ interruption frames are forwarded after the FaceMode action completes. Pipecat
168
+ 1.7 exposes the interruption event as `InterruptionFrame`; releases that expose
169
+ separate `StartInterruptionFrame` and `StopInterruptionFrame` classes are handled
170
+ without changing the public service API.
171
+
172
+ ## LiveKit token grants
173
+
174
+ Keep all LiveKit and FaceMode credentials on the server. Never put them in
175
+ browser code or log messages.
176
+
177
+ The token in `room.token` must identify the FaceMode worker participant and grant
178
+ that participant:
179
+
180
+ - `room_join=True` for the exact `LIVEKIT_ROOM_NAME`;
181
+ - `can_publish=True` so the avatar can publish its audio and video tracks;
182
+ - `can_subscribe=True` so the worker can join the room's media session; and
183
+ - a stable, unique participant identity and name if your room policy requires it.
184
+
185
+ The separate `livekit_subscriber_token` used by `FaceModeVideoService` must
186
+ identify the Pipecat subscriber and grant:
187
+
188
+ - `room_join=True` for the same room; and
189
+ - `can_subscribe=True`.
190
+
191
+ Grant subscriber publish permission only if the application needs it. A token
192
+ with publish and subscribe grants can be reused for both connections, but sharing
193
+ a participant identity between the FaceMode worker and Pipecat subscriber is not
194
+ recommended because a LiveKit room permits only one participant for an identity.
195
+
196
+ Example server-side token generation with `livekit-api`:
197
+
198
+ ```python
199
+ from livekit import api
200
+
201
+ worker_token = (
202
+ api.AccessToken()
203
+ .with_identity("facemode-avatar")
204
+ .with_name("FaceMode Avatar")
205
+ .with_grants(
206
+ api.VideoGrants(
207
+ room_join=True,
208
+ room=room_name,
209
+ can_publish=True,
210
+ can_subscribe=True,
211
+ )
212
+ )
213
+ .to_jwt()
214
+ )
215
+
216
+ subscriber_token = (
217
+ api.AccessToken()
218
+ .with_identity("pipecat-facemode-subscriber")
219
+ .with_name("Pipecat FaceMode Subscriber")
220
+ .with_grants(
221
+ api.VideoGrants(
222
+ room_join=True,
223
+ room=room_name,
224
+ can_subscribe=True,
225
+ )
226
+ )
227
+ .to_jwt()
228
+ )
229
+ ```
230
+
231
+ The sample token code is for a backend only. The LiveKit API secret must never be
232
+ sent to a client.
233
+
234
+ ## Video frame compatibility
235
+
236
+ Pipecat 1.7 uses `OutputImageRawFrame` for output video. The package also checks
237
+ for `OutputVideoRawFrame` and falls back to `ImageRawFrame`, so importing the
238
+ package remains safe across Pipecat releases that use different output video
239
+ class names. LiveKit video is requested as RGB24 when the SDK exposes that
240
+ format, then copied into a NumPy-backed RGB or RGBA image frame.
241
+
242
+ ## Lifecycle and failure behavior
243
+
244
+ - REST and WebSocket failures raise typed FaceMode exceptions without including
245
+ API keys or token values in log messages; `facemode.` credential prefixes are
246
+ redacted alongside `Bearer` material.
247
+ - The ingestion-ready poll budget and the WebSocket open/handshake budget are
248
+ each 240 seconds. The `start`/`started` acknowledgement uses
249
+ `protocol_timeout` (default 15 seconds).
250
+ - WebSocket receive, keepalive, audio, and video tasks are cancelled and awaited during `EndFrame`, `cleanup`, or a failed startup. Graceful shutdown sends `end_session` and waits up to three seconds for canonical `ended` before closing the socket.
251
+ - `ended` is a WebSocket protocol acknowledgement, not proof that backend worker cleanup, provider cancellation, or billing finalization is complete. Callers that need backend cleanup confirmation poll the public session endpoint until it becomes terminal.
252
+ - LiveKit tracks published before the connection are discovered after startup;
253
+ later `track_subscribed` events are handled automatically.
254
+ - `avatar_participant_identity` defaults to `facemode-avatar` to avoid forwarding
255
+ other remote participants. Set it to the identity in the worker room token when
256
+ that token uses a different identity. The local subscriber track is always
257
+ ignored.
@@ -0,0 +1,241 @@
1
+ # pipecat-facemode
2
+
3
+ FaceMode avatar output for Pipecat pipelines. The integration taps
4
+ `TTSAudioRawFrame`, sends canonical 16-bit PCM to FaceMode, and converts the
5
+ avatar's LiveKit audio and video tracks back into Pipecat output frames.
6
+
7
+ The package is intentionally a small `FrameProcessor`. It does not replace a
8
+ Pipecat transport. Place it after a TTS service and before the output transport:
9
+
10
+ ```text
11
+ transport input -> STT -> LLM -> TTS -> FaceModeVideoService -> transport output
12
+ ```
13
+
14
+ By default, source `TTSAudioRawFrame` objects are consumed. This prevents the
15
+ source TTS audio and the avatar's returned audio from being played twice. Set
16
+ `forward_tts_audio=True` only when the pipeline intentionally needs both.
17
+
18
+ ## Install
19
+
20
+ ```powershell
21
+ pip install pipecat-facemode
22
+ ```
23
+
24
+ From this directory:
25
+
26
+ ```powershell
27
+ pip install .
28
+ ```
29
+
30
+ The package supports Pipecat 1.7 through the current 1.x line, LiveKit RTC 1.x, aiohttp 3.x, websockets 14 through 16, and NumPy 2.x.
31
+
32
+ ## Basic usage
33
+
34
+ `room.token` is the server-side worker token sent to FaceMode. The separate
35
+ `livekit_subscriber_token` is used by this Pipecat process to subscribe to the
36
+ room. Use separate participant identities and tokens in production.
37
+
38
+ ```python
39
+ import os
40
+
41
+ from pipecat.pipeline.pipeline import Pipeline
42
+ from pipecat.services.cartesia.tts import CartesiaTTSService
43
+ from pipecat_facemode import FaceModeVideoService
44
+
45
+
46
+ tts = CartesiaTTSService(
47
+ api_key=os.environ["CARTESIA_API_KEY"],
48
+ settings=CartesiaTTSService.Settings(
49
+ voice="71a7ad14-091c-4e8e-a314-022ece01c121",
50
+ ),
51
+ )
52
+
53
+ facemode = FaceModeVideoService(
54
+ api_key=os.environ["FACEMODE_API_KEY"],
55
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
56
+ room={
57
+ "type": "livekit",
58
+ "url": os.environ["LIVEKIT_URL"],
59
+ "token": os.environ["LIVEKIT_WORKER_TOKEN"],
60
+ },
61
+ livekit_subscriber_token=os.environ["LIVEKIT_SUBSCRIBER_TOKEN"],
62
+ room_name=os.environ["LIVEKIT_ROOM_NAME"],
63
+ # Optional speech input provider persisted by the backend for the session:
64
+ # deepgram, gemini, gnani, elevenlabs, openai, cartesia, sarvam, or custom.
65
+ input_provider=os.environ.get("FACEMODE_INPUT_PROVIDER") or None,
66
+ )
67
+
68
+ pipeline = Pipeline([
69
+ transport.input(),
70
+ tts,
71
+ facemode,
72
+ transport.output(),
73
+ ])
74
+ ```
75
+
76
+ See [`examples/basic_pipeline.py`](examples/basic_pipeline.py) for a complete
77
+ pipeline using Pipecat's LiveKit transport. The same-room example disables the
78
+ transport's audio and video outputs because the FaceMode worker already publishes
79
+ both avatar tracks directly into that LiveKit room. It also uses distinct tokens
80
+ for the FaceMode worker, Pipecat subscriber, Pipecat transport, and viewer.
81
+
82
+ ## FaceMode session and WebSocket protocol
83
+
84
+ On `StartFrame`, the service:
85
+
86
+ 1. Connects to the supplied LiveKit room with `livekit-rtc` and enables automatic
87
+ track subscription.
88
+ 2. Calls `POST {api_url}/sessions` with the room object (and `inputProvider`
89
+ when `input_provider` is configured). The request never sends
90
+ `waitForIngestion`; current backends reject it as an unknown field:
91
+
92
+ ```json
93
+ {
94
+ "avatarId": "avatar-id",
95
+ "inputProvider": "deepgram",
96
+ "room": {
97
+ "type": "livekit",
98
+ "url": "wss://project.livekit.cloud",
99
+ "token": "server-side-token"
100
+ }
101
+ }
102
+ ```
103
+
104
+ A `201` response returns `ingestion.ready: true` with the worker WebSocket
105
+ `url` and a one-time `wsToken` immediately.
106
+
107
+ 3. When the response has `ingestion.ready: false`, polls `GET {api_url}/sessions/{id}` using bounded backoff for up to 240 seconds until ready WebSocket credentials are available; `FAILED` or `ENDED` worker states stop the wait immediately. Room credentials from the initial response remain in memory and are not expected in the status response.
108
+ 4. Opens the returned WebSocket with the `facemode.<ws-token>` subprotocol (the `aivatar.` prefix is rejected by current backends), compression disabled, native keepalives disabled, a 240-second open timeout, and optional backend-provided `ingestion.headers` forwarded unchanged. This package requires `websockets>=14`, so it uses the `additional_headers` API and never falls back to an unaffinitized connection.
109
+ 5. Starts the receive task, sends canonical `start` from the pipeline `StartFrame`, and waits for a validated `started` response.
110
+ 6. Starts application keepalives only after negotiation succeeds, preserving the protocol requirement that `start` is the first application message.
111
+
112
+ Call `await service.wait_for_avatar()` when an application needs to wait for
113
+ FaceMode's `audio_ready` event or the first LiveKit video frame before announcing
114
+ that avatar media is available.
115
+
116
+ The canonical protocol messages are used as follows:
117
+
118
+ - `start` negotiates `audio_encoding: pcm_s16le`, sample rate, and channel count.
119
+ - `start_utterance` precedes the first binary audio chunk.
120
+ - `TTSAudioRawFrame.audio` is sent as binary little-endian signed 16-bit PCM,
121
+ with no JSON or base64 wrapper.
122
+ - `end_utterance` follows a TTS stop frame or a short idle period.
123
+ - `cancel_utterance` is sent for `StartInterruptionFrame`.
124
+ - `ping` is sent periodically while the session is alive.
125
+ - `end_session` is sent during graceful `EndFrame` or pipeline cleanup.
126
+
127
+ ## Automatic reconnect
128
+
129
+ If the canonical WebSocket drops after a session was fully started, the service
130
+ reconnects without caller-visible pipeline failure:
131
+
132
+ 1. It calls `POST {api_url}/sessions/{id}/reconnect` with the original `room`
133
+ object (plus the persisted `inputProvider` when configured). Every response
134
+ mints a fresh one-time `wsToken`; tokens are never reused.
135
+ 2. It opens a new socket with the `facemode.<new-token>` subprotocol, resends
136
+ the same `start` negotiation, and waits for `started` before audio resumes.
137
+ 3. At most 2 reconnect attempts run with bounded backoff. Recovery is
138
+ single-flight, so simultaneous close/error notifications share one attempt.
139
+
140
+ Sequence numbers keep increasing across reconnects, an explicitly open
141
+ utterance is re-declared on the new socket, and already-sent audio is never
142
+ replayed. Sends that arrive during the gap wait for the new socket instead of
143
+ failing. No reconnect is attempted on intentional shutdown (`EndFrame`,
144
+ `CancelFrame`, `stop`, `cleanup`), on server-terminal states (`session_ending`,
145
+ `ended`, fatal `error` messages), or before the session is fully started. When
146
+ the reconnect budget is exhausted, the failure surfaces as a
147
+ `FaceModeProtocolError` that never contains token or key material.
148
+
149
+ The service calls `super().__init__()` and `super().process_frame(...)`, and
150
+ forwards non-consumed frames with their original `FrameDirection`. Lifecycle and
151
+ interruption frames are forwarded after the FaceMode action completes. Pipecat
152
+ 1.7 exposes the interruption event as `InterruptionFrame`; releases that expose
153
+ separate `StartInterruptionFrame` and `StopInterruptionFrame` classes are handled
154
+ without changing the public service API.
155
+
156
+ ## LiveKit token grants
157
+
158
+ Keep all LiveKit and FaceMode credentials on the server. Never put them in
159
+ browser code or log messages.
160
+
161
+ The token in `room.token` must identify the FaceMode worker participant and grant
162
+ that participant:
163
+
164
+ - `room_join=True` for the exact `LIVEKIT_ROOM_NAME`;
165
+ - `can_publish=True` so the avatar can publish its audio and video tracks;
166
+ - `can_subscribe=True` so the worker can join the room's media session; and
167
+ - a stable, unique participant identity and name if your room policy requires it.
168
+
169
+ The separate `livekit_subscriber_token` used by `FaceModeVideoService` must
170
+ identify the Pipecat subscriber and grant:
171
+
172
+ - `room_join=True` for the same room; and
173
+ - `can_subscribe=True`.
174
+
175
+ Grant subscriber publish permission only if the application needs it. A token
176
+ with publish and subscribe grants can be reused for both connections, but sharing
177
+ a participant identity between the FaceMode worker and Pipecat subscriber is not
178
+ recommended because a LiveKit room permits only one participant for an identity.
179
+
180
+ Example server-side token generation with `livekit-api`:
181
+
182
+ ```python
183
+ from livekit import api
184
+
185
+ worker_token = (
186
+ api.AccessToken()
187
+ .with_identity("facemode-avatar")
188
+ .with_name("FaceMode Avatar")
189
+ .with_grants(
190
+ api.VideoGrants(
191
+ room_join=True,
192
+ room=room_name,
193
+ can_publish=True,
194
+ can_subscribe=True,
195
+ )
196
+ )
197
+ .to_jwt()
198
+ )
199
+
200
+ subscriber_token = (
201
+ api.AccessToken()
202
+ .with_identity("pipecat-facemode-subscriber")
203
+ .with_name("Pipecat FaceMode Subscriber")
204
+ .with_grants(
205
+ api.VideoGrants(
206
+ room_join=True,
207
+ room=room_name,
208
+ can_subscribe=True,
209
+ )
210
+ )
211
+ .to_jwt()
212
+ )
213
+ ```
214
+
215
+ The sample token code is for a backend only. The LiveKit API secret must never be
216
+ sent to a client.
217
+
218
+ ## Video frame compatibility
219
+
220
+ Pipecat 1.7 uses `OutputImageRawFrame` for output video. The package also checks
221
+ for `OutputVideoRawFrame` and falls back to `ImageRawFrame`, so importing the
222
+ package remains safe across Pipecat releases that use different output video
223
+ class names. LiveKit video is requested as RGB24 when the SDK exposes that
224
+ format, then copied into a NumPy-backed RGB or RGBA image frame.
225
+
226
+ ## Lifecycle and failure behavior
227
+
228
+ - REST and WebSocket failures raise typed FaceMode exceptions without including
229
+ API keys or token values in log messages; `facemode.` credential prefixes are
230
+ redacted alongside `Bearer` material.
231
+ - The ingestion-ready poll budget and the WebSocket open/handshake budget are
232
+ each 240 seconds. The `start`/`started` acknowledgement uses
233
+ `protocol_timeout` (default 15 seconds).
234
+ - WebSocket receive, keepalive, audio, and video tasks are cancelled and awaited during `EndFrame`, `cleanup`, or a failed startup. Graceful shutdown sends `end_session` and waits up to three seconds for canonical `ended` before closing the socket.
235
+ - `ended` is a WebSocket protocol acknowledgement, not proof that backend worker cleanup, provider cancellation, or billing finalization is complete. Callers that need backend cleanup confirmation poll the public session endpoint until it becomes terminal.
236
+ - LiveKit tracks published before the connection are discovered after startup;
237
+ later `track_subscribed` events are handled automatically.
238
+ - `avatar_participant_identity` defaults to `facemode-avatar` to avoid forwarding
239
+ other remote participants. Set it to the identity in the worker room token when
240
+ that token uses a different identity. The local subscriber track is always
241
+ ignored.
@@ -0,0 +1,28 @@
1
+ """FaceMode integration for Pipecat."""
2
+
3
+ from .exceptions import (
4
+ FaceModeAPIError,
5
+ FaceModeConfigurationError,
6
+ FaceModeError,
7
+ FaceModeNotReadyError,
8
+ FaceModeProtocolError,
9
+ )
10
+ from .models import IngestionDetails, LiveKitRoom, SessionDetails, SessionRequest
11
+ from .service import FaceModeProcessor, FaceModeService, FaceModeVideoService
12
+ from .version import __version__
13
+
14
+ __all__ = [
15
+ "FaceModeAPIError",
16
+ "FaceModeConfigurationError",
17
+ "FaceModeError",
18
+ "FaceModeNotReadyError",
19
+ "FaceModeProcessor",
20
+ "FaceModeProtocolError",
21
+ "FaceModeService",
22
+ "FaceModeVideoService",
23
+ "IngestionDetails",
24
+ "LiveKitRoom",
25
+ "SessionDetails",
26
+ "SessionRequest",
27
+ "__version__",
28
+ ]
@@ -0,0 +1,21 @@
1
+ """Exceptions raised by the Pipecat FaceMode integration."""
2
+
3
+
4
+ class FaceModeError(RuntimeError):
5
+ """Base error for FaceMode integration failures."""
6
+
7
+
8
+ class FaceModeConfigurationError(FaceModeError):
9
+ """Raised when required integration configuration is missing or invalid."""
10
+
11
+
12
+ class FaceModeAPIError(FaceModeError):
13
+ """Raised when the FaceMode REST API rejects or cannot fulfill a request."""
14
+
15
+
16
+ class FaceModeProtocolError(FaceModeError):
17
+ """Raised when the FaceMode WebSocket protocol fails."""
18
+
19
+
20
+ class FaceModeNotReadyError(FaceModeError):
21
+ """Raised when the LiveKit avatar media stream is not ready."""