pipecat-facemode 0.2.0__tar.gz → 0.3.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.
Files changed (21) hide show
  1. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/PKG-INFO +109 -15
  2. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/README.md +105 -13
  3. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode/__init__.py +12 -1
  4. pipecat_facemode-0.3.0/pipecat_facemode/daily_client.py +700 -0
  5. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode/exceptions.py +1 -1
  6. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode/models.py +86 -9
  7. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode/service.py +399 -53
  8. pipecat_facemode-0.3.0/pipecat_facemode/version.py +3 -0
  9. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode.egg-info/PKG-INFO +109 -15
  10. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode.egg-info/SOURCES.txt +2 -0
  11. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode.egg-info/requires.txt +3 -0
  12. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pyproject.toml +5 -2
  13. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/test/test_contract.py +71 -0
  14. pipecat_facemode-0.3.0/test/test_daily.py +813 -0
  15. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/test/test_reconnect.py +123 -0
  16. pipecat_facemode-0.2.0/pipecat_facemode/version.py +0 -3
  17. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/LICENSE +0 -0
  18. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode.egg-info/dependency_links.txt +0 -0
  19. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/pipecat_facemode.egg-info/top_level.txt +0 -0
  20. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/setup.cfg +0 -0
  21. {pipecat_facemode-0.2.0 → pipecat_facemode-0.3.0}/test/test_ingestion.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pipecat-facemode
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: FaceMode avatar integration for Pipecat
5
5
  Author: FaceMode
6
6
  License-Expression: Apache-2.0
7
7
  Project-URL: Homepage, https://facemode.io
8
8
  Project-URL: Repository, https://github.com/facemode-by-infinitylevel/facemode-integrations
9
- Keywords: pipecat,avatar,facemode,ai,video,realtime,livekit
9
+ Keywords: pipecat,avatar,facemode,ai,video,realtime,livekit,daily
10
10
  Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Programming Language :: Python :: 3.13
@@ -19,13 +19,15 @@ Requires-Dist: livekit<2,>=1.1
19
19
  Requires-Dist: aiohttp<4,>=3.10
20
20
  Requires-Dist: websockets<17,>=14
21
21
  Requires-Dist: numpy<3,>=2
22
+ Provides-Extra: daily
23
+ Requires-Dist: daily-python<1,>=0.31; extra == "daily"
22
24
  Dynamic: license-file
23
25
 
24
26
  # pipecat-facemode
25
27
 
26
- FaceMode avatar output for Pipecat pipelines. The integration taps
28
+ [FaceMode](https://facemode.io) avatar output for Pipecat pipelines. The integration taps
27
29
  `TTSAudioRawFrame`, sends canonical 16-bit PCM to FaceMode, and converts the
28
- avatar's LiveKit audio and video tracks back into Pipecat output frames.
30
+ avatar's LiveKit or Daily room audio and video back into Pipecat output frames.
29
31
 
30
32
  The package is intentionally a small `FrameProcessor`. It does not replace a
31
33
  Pipecat transport. Place it after a TTS service and before the output transport:
@@ -44,19 +46,26 @@ source TTS audio and the avatar's returned audio from being played twice. Set
44
46
  pip install pipecat-facemode
45
47
  ```
46
48
 
49
+ For Daily rooms, also install the Daily extra:
50
+
51
+ ```bash
52
+ pip install "pipecat-facemode[daily]"
53
+ ```
54
+
47
55
  From this directory:
48
56
 
49
57
  ```bash
50
58
  pip install .
51
59
  ```
52
60
 
53
- 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. Requires Python 3.13 or later.
61
+ The package supports Pipecat 1.7 through the current 1.x line, LiveKit RTC 1.x, daily-python 0.31 or later (optional), aiohttp 3.x, websockets 14 through 16, and NumPy 2.x. Requires Python 3.13 or later.
54
62
 
55
63
  ## Basic usage
56
64
 
57
65
  `room.token` is the server-side worker token sent to FaceMode. The separate
58
- `livekit_subscriber_token` is used by this Pipecat process to subscribe to the
59
- room. Use separate participant identities and tokens in production.
66
+ `subscriber_token` (`livekit_subscriber_token` remains as a LiveKit-only alias)
67
+ is used by this Pipecat process to subscribe to the room. Use separate
68
+ participant identities and tokens in production.
60
69
 
61
70
  ```python
62
71
  import os
@@ -102,12 +111,39 @@ transport's audio and video outputs because the FaceMode worker already publishe
102
111
  both avatar tracks directly into that LiveKit room. It also uses distinct tokens
103
112
  for the FaceMode worker, Pipecat subscriber, Pipecat transport, and viewer.
104
113
 
114
+ ## Daily rooms
115
+
116
+ Daily rooms work the same way through `room.type: "daily"`. The service joins
117
+ the room with a receive-only `daily-python` `CallClient`, matches the FaceMode
118
+ worker participant by its Daily `userName` (`avatar_participant_identity`,
119
+ default `facemode-avatar`), and forwards the worker's camera and microphone
120
+ renderer frames into the pipeline.
121
+
122
+ ```python
123
+ facemode = FaceModeVideoService(
124
+ api_key=os.environ["FACEMODE_API_KEY"],
125
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
126
+ room={
127
+ "type": "daily",
128
+ "url": os.environ["DAILY_ROOM_URL"], # https://<domain>.daily.co/<room>
129
+ "token": os.environ["DAILY_WORKER_TOKEN"], # meeting token for the worker
130
+ },
131
+ subscriber_token=os.environ["DAILY_SUBSCRIBER_TOKEN"],
132
+ avatar_participant_identity="facemode-avatar",
133
+ )
134
+ ```
135
+
136
+ See [`examples/daily_pipeline.py`](examples/daily_pipeline.py) for a complete
137
+ pipeline using Pipecat's `DailyTransport`. Daily support requires
138
+ `pip install "pipecat-facemode[daily]"`; without it, configuring a Daily room
139
+ raises `FaceModeConfigurationError` with install instructions.
140
+
105
141
  ## FaceMode session and WebSocket protocol
106
142
 
107
143
  On `StartFrame`, the service:
108
144
 
109
- 1. Connects to the supplied LiveKit room with `livekit-rtc` and enables automatic
110
- track subscription.
145
+ 1. Connects to the supplied room (`livekit.rtc` for LiveKit rooms, a
146
+ receive-only `daily-python` `CallClient` for Daily rooms).
111
147
  2. Calls `POST {api_url}/sessions` with the room object (and `inputProvider`
112
148
  when `input_provider` is configured). The request never sends
113
149
  `waitForIngestion`; current backends reject it as an unknown field:
@@ -133,7 +169,7 @@ On `StartFrame`, the service:
133
169
  6. Starts application keepalives only after negotiation succeeds, preserving the protocol requirement that `start` is the first application message.
134
170
 
135
171
  Call `await service.wait_for_avatar()` when an application needs to wait for
136
- FaceMode's `audio_ready` event or the first LiveKit video frame before announcing
172
+ FaceMode's `audio_ready` event or the first room video frame before announcing
137
173
  that avatar media is available.
138
174
 
139
175
  The canonical protocol messages are used as follows:
@@ -238,13 +274,67 @@ subscriber_token = (
238
274
  The sample token code is for a backend only. The LiveKit API secret must never be
239
275
  sent to a client.
240
276
 
277
+ ## Daily meeting tokens
278
+
279
+ Keep all Daily and FaceMode credentials on the server. Never put them in
280
+ browser code or log messages.
281
+
282
+ Daily meeting tokens are minted through the Daily REST API
283
+ (`POST /meeting-tokens`). The token in `room.token` must identify the FaceMode
284
+ worker participant:
285
+
286
+ - `properties.room_name` set to the Daily room name in `room.url`;
287
+ - `properties.user_name` set to the value the plugin filters on
288
+ (`avatar_participant_identity`, default `facemode-avatar`); and
289
+ - publish permissions for camera and microphone so the worker can publish
290
+ avatar media (for example `permissions.canSend: ["video", "audio"]`, or an
291
+ owner token).
292
+
293
+ The separate `subscriber_token` used by `FaceModeVideoService` must identify
294
+ the Pipecat subscriber with a different `user_name` (for example
295
+ `pipecat-facemode-subscriber`) for the same `room_name`. Reusing the worker
296
+ meeting token also works, but the subscriber then shares the avatar's
297
+ `user_name`, which is not recommended.
298
+
299
+ ```python
300
+ import requests
301
+
302
+ worker_token = requests.post(
303
+ "https://api.daily.co/v1/meeting-tokens",
304
+ headers={"Authorization": f"Bearer {DAILY_API_KEY}"},
305
+ json={
306
+ "properties": {
307
+ "room_name": room_name,
308
+ "user_name": "facemode-avatar",
309
+ "is_owner": True,
310
+ }
311
+ },
312
+ ).json()["token"]
313
+
314
+ subscriber_token = requests.post(
315
+ "https://api.daily.co/v1/meeting-tokens",
316
+ headers={"Authorization": f"Bearer {DAILY_API_KEY}"},
317
+ json={
318
+ "properties": {
319
+ "room_name": room_name,
320
+ "user_name": "pipecat-facemode-subscriber",
321
+ }
322
+ },
323
+ ).json()["token"]
324
+ ```
325
+
326
+ The sample token code is for a backend only. The Daily API key must never be
327
+ sent to a client.
328
+
241
329
  ## Video frame compatibility
242
330
 
243
331
  Pipecat 1.7 uses `OutputImageRawFrame` for output video. The package also checks
244
332
  for `OutputVideoRawFrame` and falls back to `ImageRawFrame`, so importing the
245
333
  package remains safe across Pipecat releases that use different output video
246
334
  class names. LiveKit video is requested as RGB24 when the SDK exposes that
247
- format, then copied into a NumPy-backed RGB or RGBA image frame.
335
+ format; Daily video is requested as RGB (with an RGBA fallback) through
336
+ `set_video_renderer`. Both are copied into NumPy-backed RGB or RGBA image
337
+ frames.
248
338
 
249
339
  ## Lifecycle and failure behavior
250
340
 
@@ -256,11 +346,15 @@ format, then copied into a NumPy-backed RGB or RGBA image frame.
256
346
  `protocol_timeout` (default 15 seconds).
257
347
  - 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.
258
348
  - `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.
259
- - LiveKit tracks published before the connection are discovered after startup;
260
- later `track_subscribed` events are handled automatically.
349
+ - Room media published before the connection is discovered after startup
350
+ (LiveKit `track_subscribed` and the initial room scan; Daily `participants()`
351
+ scan plus `on_participant_joined` events). Media that appears later is
352
+ handled automatically.
261
353
  - `avatar_participant_identity` defaults to `facemode-avatar` to avoid forwarding
262
- other remote participants. Set it to the identity in the worker room token when
263
- that token uses a different identity. The local subscriber track is always
354
+ other remote participants. For LiveKit it matches the participant identity;
355
+ for Daily it matches the participant `userName` from the worker meeting
356
+ token. Set it to the identity or user name in the worker room token when
357
+ that token uses a different value. The local subscriber media is always
264
358
  ignored.
265
359
 
266
360
  ## License
@@ -1,8 +1,8 @@
1
1
  # pipecat-facemode
2
2
 
3
- FaceMode avatar output for Pipecat pipelines. The integration taps
3
+ [FaceMode](https://facemode.io) avatar output for Pipecat pipelines. The integration taps
4
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.
5
+ avatar's LiveKit or Daily room audio and video back into Pipecat output frames.
6
6
 
7
7
  The package is intentionally a small `FrameProcessor`. It does not replace a
8
8
  Pipecat transport. Place it after a TTS service and before the output transport:
@@ -21,19 +21,26 @@ source TTS audio and the avatar's returned audio from being played twice. Set
21
21
  pip install pipecat-facemode
22
22
  ```
23
23
 
24
+ For Daily rooms, also install the Daily extra:
25
+
26
+ ```bash
27
+ pip install "pipecat-facemode[daily]"
28
+ ```
29
+
24
30
  From this directory:
25
31
 
26
32
  ```bash
27
33
  pip install .
28
34
  ```
29
35
 
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. Requires Python 3.13 or later.
36
+ The package supports Pipecat 1.7 through the current 1.x line, LiveKit RTC 1.x, daily-python 0.31 or later (optional), aiohttp 3.x, websockets 14 through 16, and NumPy 2.x. Requires Python 3.13 or later.
31
37
 
32
38
  ## Basic usage
33
39
 
34
40
  `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.
41
+ `subscriber_token` (`livekit_subscriber_token` remains as a LiveKit-only alias)
42
+ is used by this Pipecat process to subscribe to the room. Use separate
43
+ participant identities and tokens in production.
37
44
 
38
45
  ```python
39
46
  import os
@@ -79,12 +86,39 @@ transport's audio and video outputs because the FaceMode worker already publishe
79
86
  both avatar tracks directly into that LiveKit room. It also uses distinct tokens
80
87
  for the FaceMode worker, Pipecat subscriber, Pipecat transport, and viewer.
81
88
 
89
+ ## Daily rooms
90
+
91
+ Daily rooms work the same way through `room.type: "daily"`. The service joins
92
+ the room with a receive-only `daily-python` `CallClient`, matches the FaceMode
93
+ worker participant by its Daily `userName` (`avatar_participant_identity`,
94
+ default `facemode-avatar`), and forwards the worker's camera and microphone
95
+ renderer frames into the pipeline.
96
+
97
+ ```python
98
+ facemode = FaceModeVideoService(
99
+ api_key=os.environ["FACEMODE_API_KEY"],
100
+ avatar_id=os.environ.get("FACEMODE_AVATAR_ID", ""),
101
+ room={
102
+ "type": "daily",
103
+ "url": os.environ["DAILY_ROOM_URL"], # https://<domain>.daily.co/<room>
104
+ "token": os.environ["DAILY_WORKER_TOKEN"], # meeting token for the worker
105
+ },
106
+ subscriber_token=os.environ["DAILY_SUBSCRIBER_TOKEN"],
107
+ avatar_participant_identity="facemode-avatar",
108
+ )
109
+ ```
110
+
111
+ See [`examples/daily_pipeline.py`](examples/daily_pipeline.py) for a complete
112
+ pipeline using Pipecat's `DailyTransport`. Daily support requires
113
+ `pip install "pipecat-facemode[daily]"`; without it, configuring a Daily room
114
+ raises `FaceModeConfigurationError` with install instructions.
115
+
82
116
  ## FaceMode session and WebSocket protocol
83
117
 
84
118
  On `StartFrame`, the service:
85
119
 
86
- 1. Connects to the supplied LiveKit room with `livekit-rtc` and enables automatic
87
- track subscription.
120
+ 1. Connects to the supplied room (`livekit.rtc` for LiveKit rooms, a
121
+ receive-only `daily-python` `CallClient` for Daily rooms).
88
122
  2. Calls `POST {api_url}/sessions` with the room object (and `inputProvider`
89
123
  when `input_provider` is configured). The request never sends
90
124
  `waitForIngestion`; current backends reject it as an unknown field:
@@ -110,7 +144,7 @@ On `StartFrame`, the service:
110
144
  6. Starts application keepalives only after negotiation succeeds, preserving the protocol requirement that `start` is the first application message.
111
145
 
112
146
  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
147
+ FaceMode's `audio_ready` event or the first room video frame before announcing
114
148
  that avatar media is available.
115
149
 
116
150
  The canonical protocol messages are used as follows:
@@ -215,13 +249,67 @@ subscriber_token = (
215
249
  The sample token code is for a backend only. The LiveKit API secret must never be
216
250
  sent to a client.
217
251
 
252
+ ## Daily meeting tokens
253
+
254
+ Keep all Daily and FaceMode credentials on the server. Never put them in
255
+ browser code or log messages.
256
+
257
+ Daily meeting tokens are minted through the Daily REST API
258
+ (`POST /meeting-tokens`). The token in `room.token` must identify the FaceMode
259
+ worker participant:
260
+
261
+ - `properties.room_name` set to the Daily room name in `room.url`;
262
+ - `properties.user_name` set to the value the plugin filters on
263
+ (`avatar_participant_identity`, default `facemode-avatar`); and
264
+ - publish permissions for camera and microphone so the worker can publish
265
+ avatar media (for example `permissions.canSend: ["video", "audio"]`, or an
266
+ owner token).
267
+
268
+ The separate `subscriber_token` used by `FaceModeVideoService` must identify
269
+ the Pipecat subscriber with a different `user_name` (for example
270
+ `pipecat-facemode-subscriber`) for the same `room_name`. Reusing the worker
271
+ meeting token also works, but the subscriber then shares the avatar's
272
+ `user_name`, which is not recommended.
273
+
274
+ ```python
275
+ import requests
276
+
277
+ worker_token = requests.post(
278
+ "https://api.daily.co/v1/meeting-tokens",
279
+ headers={"Authorization": f"Bearer {DAILY_API_KEY}"},
280
+ json={
281
+ "properties": {
282
+ "room_name": room_name,
283
+ "user_name": "facemode-avatar",
284
+ "is_owner": True,
285
+ }
286
+ },
287
+ ).json()["token"]
288
+
289
+ subscriber_token = requests.post(
290
+ "https://api.daily.co/v1/meeting-tokens",
291
+ headers={"Authorization": f"Bearer {DAILY_API_KEY}"},
292
+ json={
293
+ "properties": {
294
+ "room_name": room_name,
295
+ "user_name": "pipecat-facemode-subscriber",
296
+ }
297
+ },
298
+ ).json()["token"]
299
+ ```
300
+
301
+ The sample token code is for a backend only. The Daily API key must never be
302
+ sent to a client.
303
+
218
304
  ## Video frame compatibility
219
305
 
220
306
  Pipecat 1.7 uses `OutputImageRawFrame` for output video. The package also checks
221
307
  for `OutputVideoRawFrame` and falls back to `ImageRawFrame`, so importing the
222
308
  package remains safe across Pipecat releases that use different output video
223
309
  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.
310
+ format; Daily video is requested as RGB (with an RGBA fallback) through
311
+ `set_video_renderer`. Both are copied into NumPy-backed RGB or RGBA image
312
+ frames.
225
313
 
226
314
  ## Lifecycle and failure behavior
227
315
 
@@ -233,11 +321,15 @@ format, then copied into a NumPy-backed RGB or RGBA image frame.
233
321
  `protocol_timeout` (default 15 seconds).
234
322
  - 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
323
  - `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.
324
+ - Room media published before the connection is discovered after startup
325
+ (LiveKit `track_subscribed` and the initial room scan; Daily `participants()`
326
+ scan plus `on_participant_joined` events). Media that appears later is
327
+ handled automatically.
238
328
  - `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
329
+ other remote participants. For LiveKit it matches the participant identity;
330
+ for Daily it matches the participant `userName` from the worker meeting
331
+ token. Set it to the identity or user name in the worker room token when
332
+ that token uses a different value. The local subscriber media is always
241
333
  ignored.
242
334
 
243
335
  ## License
@@ -7,11 +7,20 @@ from .exceptions import (
7
7
  FaceModeNotReadyError,
8
8
  FaceModeProtocolError,
9
9
  )
10
- from .models import IngestionDetails, LiveKitRoom, SessionDetails, SessionRequest
10
+ from .models import (
11
+ DailyRoom,
12
+ IngestionDetails,
13
+ LiveKitRoom,
14
+ Room,
15
+ SessionDetails,
16
+ SessionRequest,
17
+ parse_room,
18
+ )
11
19
  from .service import FaceModeProcessor, FaceModeService, FaceModeVideoService
12
20
  from .version import __version__
13
21
 
14
22
  __all__ = [
23
+ "DailyRoom",
15
24
  "FaceModeAPIError",
16
25
  "FaceModeConfigurationError",
17
26
  "FaceModeError",
@@ -22,7 +31,9 @@ __all__ = [
22
31
  "FaceModeVideoService",
23
32
  "IngestionDetails",
24
33
  "LiveKitRoom",
34
+ "Room",
25
35
  "SessionDetails",
26
36
  "SessionRequest",
27
37
  "__version__",
38
+ "parse_room",
28
39
  ]