pipecat-stork 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.
- pipecat_stork-0.1.0/.gitignore +7 -0
- pipecat_stork-0.1.0/CHANGELOG.md +5 -0
- pipecat_stork-0.1.0/LICENSE +202 -0
- pipecat_stork-0.1.0/PKG-INFO +102 -0
- pipecat_stork-0.1.0/README.md +82 -0
- pipecat_stork-0.1.0/example/.env.example +1 -0
- pipecat_stork-0.1.0/example/bot.py +51 -0
- pipecat_stork-0.1.0/example/index.html +47 -0
- pipecat_stork-0.1.0/example/requirements.txt +3 -0
- pipecat_stork-0.1.0/pyproject.toml +29 -0
- pipecat_stork-0.1.0/src/pipecat_stork/__init__.py +6 -0
- pipecat_stork-0.1.0/src/pipecat_stork/avatar.py +104 -0
- pipecat_stork-0.1.0/tests/test_avatar.py +52 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pipecat-stork
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Stork Live avatars for Pipecat: a talking avatar the browser draws itself, with no API key and no per-minute charge
|
|
5
|
+
Project-URL: Homepage, https://www.stork.ai/live
|
|
6
|
+
Project-URL: Source, https://github.com/jupiterspins/stork-live/tree/main/integrations/pipecat
|
|
7
|
+
Project-URL: Changelog, https://github.com/jupiterspins/stork-live/blob/main/integrations/pipecat/CHANGELOG.md
|
|
8
|
+
Author-email: Stork <support@stork.ai>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,avatar,lip-sync,pipecat,realtime,stork,voice
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
17
|
+
Requires-Python: >=3.10
|
|
18
|
+
Requires-Dist: pipecat-ai>=1.4.0
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# pipecat-stork
|
|
22
|
+
|
|
23
|
+
[Stork Live](https://www.stork.ai/live) avatars for [Pipecat](https://github.com/pipecat-ai/pipecat): a talking avatar that the user's browser draws itself.
|
|
24
|
+
|
|
25
|
+
This integration is built and maintained by Stork, the company behind Stork Live.
|
|
26
|
+
|
|
27
|
+
## How it differs from a video service
|
|
28
|
+
|
|
29
|
+
A Stork Live avatar is a file of about 8 MB that the browser downloads and draws. A small model in the page moves the lips from the bot's voice. So:
|
|
30
|
+
|
|
31
|
+
- there is no API key and no account, and nothing is billed per minute. The library faces are free and carry a "Powered by stork.ai" mark;
|
|
32
|
+
- the bot produces no video, and its audio is not changed or redirected;
|
|
33
|
+
- the only thing the bot does is tell the page which face to draw.
|
|
34
|
+
|
|
35
|
+
`StorkLiveAvatar` is a pass-through processor that sends that name to the client as an RTVI server message.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install "pipecat-stork @ git+https://github.com/jupiterspins/stork-live#subdirectory=integrations/pipecat"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage with a Pipecat pipeline
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from pipecat_stork import StorkLiveAvatar
|
|
47
|
+
|
|
48
|
+
avatar = StorkLiveAvatar(avatar="a") # "a" to "d" are free library faces
|
|
49
|
+
|
|
50
|
+
pipeline = Pipeline([transport.input(), stt, llm, tts, avatar, transport.output()])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
`avatar` can also be the https address of an avatar file of your own. When it is omitted, the processor reads `STORK_AVATAR`, then uses `"a"`. `await avatar.set_avatar("c")` switches the face during a call. RTVI must be enabled on the task, which is Pipecat's default.
|
|
54
|
+
|
|
55
|
+
In the page:
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { attachToPipecat } from 'stork-live/pipecat'
|
|
59
|
+
|
|
60
|
+
const face = attachToPipecat(client, canvas, { audioContext }) // before client.connect()
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`attachToPipecat` draws the face the bot named and moves its lips with the bot's voice. The avatar plays that voice itself, about a third of a second late, so lips and sound line up. Do not also attach the bot's audio track to an `<audio>` element, or the voice is heard twice. If the named face cannot be loaded, it reports the error and draws the default face.
|
|
64
|
+
|
|
65
|
+
Browsers only start sound after a click. Open `new AudioContext({ sampleRate: 16000 })` in your click handler and pass it as `audioContext`.
|
|
66
|
+
|
|
67
|
+
## Running the example
|
|
68
|
+
|
|
69
|
+
[`example/`](example) is a bot that speaks a greeting, and a page.
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
cd example
|
|
73
|
+
cp .env.example .env # then fill in OPENAI_API_KEY
|
|
74
|
+
python -m venv .venv && source .venv/bin/activate
|
|
75
|
+
pip install -r requirements.txt
|
|
76
|
+
|
|
77
|
+
python bot.py # terminal 1, listens on http://localhost:7860
|
|
78
|
+
python -m http.server 8000 # terminal 2, serves the page
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Open http://localhost:8000 and press "Start talking".
|
|
82
|
+
|
|
83
|
+
## Limits
|
|
84
|
+
|
|
85
|
+
- Head and shoulders at 512 pixels. No hands, no body, no camera moves.
|
|
86
|
+
- The lip model was trained on English.
|
|
87
|
+
- The page helper is for browsers. In a native app, run it in a web view.
|
|
88
|
+
- Interruptions need nothing special: the lips follow whatever audio the bot sends, and stop when it stops.
|
|
89
|
+
|
|
90
|
+
## Compatibility
|
|
91
|
+
|
|
92
|
+
Tested with Pipecat v1.17.0, `@pipecat-ai/client-js` 1.18 and `@pipecat-ai/small-webrtc-transport` 1.11 in Chrome, on 2 December 2026.
|
|
93
|
+
|
|
94
|
+
## Tests
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
uv run --with pytest --with-editable . pytest tests
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
Apache-2.0. See [CHANGELOG.md](CHANGELOG.md) for changes.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# pipecat-stork
|
|
2
|
+
|
|
3
|
+
[Stork Live](https://www.stork.ai/live) avatars for [Pipecat](https://github.com/pipecat-ai/pipecat): a talking avatar that the user's browser draws itself.
|
|
4
|
+
|
|
5
|
+
This integration is built and maintained by Stork, the company behind Stork Live.
|
|
6
|
+
|
|
7
|
+
## How it differs from a video service
|
|
8
|
+
|
|
9
|
+
A Stork Live avatar is a file of about 8 MB that the browser downloads and draws. A small model in the page moves the lips from the bot's voice. So:
|
|
10
|
+
|
|
11
|
+
- there is no API key and no account, and nothing is billed per minute. The library faces are free and carry a "Powered by stork.ai" mark;
|
|
12
|
+
- the bot produces no video, and its audio is not changed or redirected;
|
|
13
|
+
- the only thing the bot does is tell the page which face to draw.
|
|
14
|
+
|
|
15
|
+
`StorkLiveAvatar` is a pass-through processor that sends that name to the client as an RTVI server message.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install "pipecat-stork @ git+https://github.com/jupiterspins/stork-live#subdirectory=integrations/pipecat"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage with a Pipecat pipeline
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
from pipecat_stork import StorkLiveAvatar
|
|
27
|
+
|
|
28
|
+
avatar = StorkLiveAvatar(avatar="a") # "a" to "d" are free library faces
|
|
29
|
+
|
|
30
|
+
pipeline = Pipeline([transport.input(), stt, llm, tts, avatar, transport.output()])
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`avatar` can also be the https address of an avatar file of your own. When it is omitted, the processor reads `STORK_AVATAR`, then uses `"a"`. `await avatar.set_avatar("c")` switches the face during a call. RTVI must be enabled on the task, which is Pipecat's default.
|
|
34
|
+
|
|
35
|
+
In the page:
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { attachToPipecat } from 'stork-live/pipecat'
|
|
39
|
+
|
|
40
|
+
const face = attachToPipecat(client, canvas, { audioContext }) // before client.connect()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`attachToPipecat` draws the face the bot named and moves its lips with the bot's voice. The avatar plays that voice itself, about a third of a second late, so lips and sound line up. Do not also attach the bot's audio track to an `<audio>` element, or the voice is heard twice. If the named face cannot be loaded, it reports the error and draws the default face.
|
|
44
|
+
|
|
45
|
+
Browsers only start sound after a click. Open `new AudioContext({ sampleRate: 16000 })` in your click handler and pass it as `audioContext`.
|
|
46
|
+
|
|
47
|
+
## Running the example
|
|
48
|
+
|
|
49
|
+
[`example/`](example) is a bot that speaks a greeting, and a page.
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
cd example
|
|
53
|
+
cp .env.example .env # then fill in OPENAI_API_KEY
|
|
54
|
+
python -m venv .venv && source .venv/bin/activate
|
|
55
|
+
pip install -r requirements.txt
|
|
56
|
+
|
|
57
|
+
python bot.py # terminal 1, listens on http://localhost:7860
|
|
58
|
+
python -m http.server 8000 # terminal 2, serves the page
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Open http://localhost:8000 and press "Start talking".
|
|
62
|
+
|
|
63
|
+
## Limits
|
|
64
|
+
|
|
65
|
+
- Head and shoulders at 512 pixels. No hands, no body, no camera moves.
|
|
66
|
+
- The lip model was trained on English.
|
|
67
|
+
- The page helper is for browsers. In a native app, run it in a web view.
|
|
68
|
+
- Interruptions need nothing special: the lips follow whatever audio the bot sends, and stop when it stops.
|
|
69
|
+
|
|
70
|
+
## Compatibility
|
|
71
|
+
|
|
72
|
+
Tested with Pipecat v1.17.0, `@pipecat-ai/client-js` 1.18 and `@pipecat-ai/small-webrtc-transport` 1.11 in Chrome, on 2 December 2026.
|
|
73
|
+
|
|
74
|
+
## Tests
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
uv run --with pytest --with-editable . pytest tests
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
Apache-2.0. See [CHANGELOG.md](CHANGELOG.md) for changes.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
OPENAI_API_KEY=
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from dotenv import load_dotenv
|
|
4
|
+
from pipecat.frames.frames import TTSSpeakFrame
|
|
5
|
+
from pipecat.pipeline.pipeline import Pipeline
|
|
6
|
+
from pipecat.pipeline.runner import PipelineRunner
|
|
7
|
+
from pipecat.pipeline.task import PipelineTask
|
|
8
|
+
from pipecat.runner.types import RunnerArguments
|
|
9
|
+
from pipecat.runner.utils import create_transport
|
|
10
|
+
from pipecat.services.openai.tts import OpenAITTSService
|
|
11
|
+
from pipecat.transports.base_transport import TransportParams
|
|
12
|
+
|
|
13
|
+
from pipecat_stork import StorkLiveAvatar
|
|
14
|
+
|
|
15
|
+
load_dotenv() # OPENAI_API_KEY
|
|
16
|
+
|
|
17
|
+
GREETING = (
|
|
18
|
+
"Hello, I am a Pipecat bot speaking through a Stork Live avatar. "
|
|
19
|
+
"My voice travels over WebRTC and the page moves my lips to match it."
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# The smallest bot that speaks. Put your own speech-to-text and LLM between transport.input() and tts.
|
|
24
|
+
async def bot(runner_args: RunnerArguments):
|
|
25
|
+
transport = await create_transport(
|
|
26
|
+
runner_args,
|
|
27
|
+
{"webrtc": lambda: TransportParams(audio_in_enabled=True, audio_out_enabled=True)},
|
|
28
|
+
)
|
|
29
|
+
tts = OpenAITTSService(api_key=os.environ["OPENAI_API_KEY"])
|
|
30
|
+
|
|
31
|
+
# Tell the page which face to draw. No video is produced and the audio is not touched:
|
|
32
|
+
# the browser draws the avatar and moves its lips from the bot's voice.
|
|
33
|
+
avatar = StorkLiveAvatar(avatar="b") # "a" to "d" are free; or the https address of your own avatar
|
|
34
|
+
|
|
35
|
+
task = PipelineTask(Pipeline([transport.input(), tts, avatar, transport.output()]))
|
|
36
|
+
|
|
37
|
+
@transport.event_handler("on_client_connected")
|
|
38
|
+
async def on_connected(transport, client):
|
|
39
|
+
await task.queue_frames([TTSSpeakFrame(GREETING)])
|
|
40
|
+
|
|
41
|
+
@transport.event_handler("on_client_disconnected")
|
|
42
|
+
async def on_disconnected(transport, client):
|
|
43
|
+
await task.cancel()
|
|
44
|
+
|
|
45
|
+
await PipelineRunner(handle_sigint=runner_args.handle_sigint).run(task)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
from pipecat.runner.run import main # serves POST /api/offer on port 7860
|
|
50
|
+
|
|
51
|
+
main()
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<meta charset="utf-8"><meta name="viewport" content="width=device-width">
|
|
3
|
+
<title>Stork Live with pipecat-stork</title>
|
|
4
|
+
<style>
|
|
5
|
+
body { background: #0f1115; color: #e6e6e6; font: 15px system-ui; margin: 24px; max-width: 560px }
|
|
6
|
+
canvas { width: min(512px, 92vw); aspect-ratio: 1; border-radius: 12px; display: block; background: #000 }
|
|
7
|
+
button { margin: 12px 8px 0 0; padding: 9px 16px; font-size: 15px; border-radius: 8px; border: 1px solid #333; background: #1b1f27; color: #e6e6e6 }
|
|
8
|
+
button:disabled { opacity: .5 }
|
|
9
|
+
#status { margin-top: 12px; color: #9aa }
|
|
10
|
+
</style>
|
|
11
|
+
<canvas id="face"></canvas>
|
|
12
|
+
<button id="start">Start talking</button><button id="stop" disabled>Stop</button>
|
|
13
|
+
<div id="status">Press "Start talking". The bot chooses the face.</div>
|
|
14
|
+
<script type="module">
|
|
15
|
+
import { attachToPipecat } from 'https://cdn.jsdelivr.net/npm/stork-live@0.1/src/pipecat.js'
|
|
16
|
+
import { PipecatClient } from 'https://esm.sh/@pipecat-ai/client-js@1.18'
|
|
17
|
+
import { SmallWebRTCTransport } from 'https://esm.sh/@pipecat-ai/small-webrtc-transport@1.11'
|
|
18
|
+
|
|
19
|
+
// where bot.py listens. Change with ?bot=http://host:port
|
|
20
|
+
const BOT = new URLSearchParams(location.search).get('bot') || 'http://localhost:7860'
|
|
21
|
+
|
|
22
|
+
const $ = (id) => document.getElementById(id), say = (text) => { $('status').textContent = text }
|
|
23
|
+
let client, face
|
|
24
|
+
|
|
25
|
+
$('start').onclick = async () => {
|
|
26
|
+
$('start').disabled = true; say('Connecting to the bot…')
|
|
27
|
+
try {
|
|
28
|
+
// browsers only start sound after a click, so open the audio context here
|
|
29
|
+
const AC = window.AudioContext || window.webkitAudioContext
|
|
30
|
+
const audioContext = new AC({ sampleRate: 16000 }); audioContext.resume()
|
|
31
|
+
|
|
32
|
+
client = new PipecatClient({ transport: new SmallWebRTCTransport(), enableMic: true })
|
|
33
|
+
// draws the face the bot names and moves its lips with the bot's voice.
|
|
34
|
+
// The avatar plays that voice itself: do not attach the bot's audio track.
|
|
35
|
+
face = attachToPipecat(client, $('face'), {
|
|
36
|
+
audioContext,
|
|
37
|
+
onAvatar: (name) => say('The bot chose face "' + name + '".'),
|
|
38
|
+
onError: (e) => say('Avatar: ' + (e.message || e)),
|
|
39
|
+
})
|
|
40
|
+
client.on('disconnected', () => { face.detach(); $('start').disabled = false; $('stop').disabled = true; say('Disconnected.') })
|
|
41
|
+
await client.connect({ webrtcUrl: BOT + '/api/offer' })
|
|
42
|
+
$('stop').disabled = false
|
|
43
|
+
} catch (e) { say('Error: ' + (e.message || e)); $('start').disabled = false }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
$('stop').onclick = () => client && client.disconnect()
|
|
47
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pipecat-stork"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Stork Live avatars for Pipecat: a talking avatar the browser draws itself, with no API key and no per-minute charge"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Stork", email = "support@stork.ai" }]
|
|
13
|
+
keywords = ["pipecat", "avatar", "voice", "ai", "realtime", "lip-sync", "stork"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Topic :: Multimedia :: Sound/Audio",
|
|
18
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
]
|
|
21
|
+
dependencies = ["pipecat-ai>=1.4.0"]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://www.stork.ai/live"
|
|
25
|
+
Source = "https://github.com/jupiterspins/stork-live/tree/main/integrations/pipecat"
|
|
26
|
+
Changelog = "https://github.com/jupiterspins/stork-live/blob/main/integrations/pipecat/CHANGELOG.md"
|
|
27
|
+
|
|
28
|
+
[tool.hatch.build.targets.wheel]
|
|
29
|
+
packages = ["src/pipecat_stork"]
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2026, Stork
|
|
3
|
+
#
|
|
4
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
"""Stork Live avatar processor for Pipecat.
|
|
8
|
+
|
|
9
|
+
A Stork Live avatar is drawn by the user's browser, and the lip movement is
|
|
10
|
+
worked out there from the bot's voice. So this processor produces no video and
|
|
11
|
+
changes no audio. It tells the client which avatar to draw, with an RTVI server
|
|
12
|
+
message, and passes every frame through unchanged.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import re
|
|
17
|
+
from urllib.parse import urlsplit
|
|
18
|
+
|
|
19
|
+
from pipecat.frames.frames import (
|
|
20
|
+
BotStartedSpeakingFrame,
|
|
21
|
+
ClientConnectedFrame,
|
|
22
|
+
Frame,
|
|
23
|
+
TTSStartedFrame,
|
|
24
|
+
)
|
|
25
|
+
from pipecat.processors.frame_processor import FrameDirection, FrameProcessor
|
|
26
|
+
from pipecat.processors.frameworks.rtvi.frames import RTVIServerMessageFrame
|
|
27
|
+
|
|
28
|
+
MESSAGE_TYPE = "stork-avatar"
|
|
29
|
+
DEFAULT_AVATAR = "a"
|
|
30
|
+
_LIBRARY_NAME = re.compile(r"^[a-z0-9][a-z0-9_-]{0,63}$")
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class StorkLiveAvatar(FrameProcessor):
|
|
34
|
+
"""Names the Stork Live avatar the client should draw.
|
|
35
|
+
|
|
36
|
+
Put it anywhere in the pipeline, for example just before
|
|
37
|
+
``transport.output()``. It needs no API key and starts no session with any
|
|
38
|
+
server. The client draws the avatar with the ``stork-live`` npm package and
|
|
39
|
+
moves its lips from the bot's audio track.
|
|
40
|
+
|
|
41
|
+
The avatar name is sent when a client connects and again each time the bot
|
|
42
|
+
starts to speak, so a client that joins late still receives it.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
avatar: A face from Stork's free library (``"a"`` to ``"d"``), or the
|
|
46
|
+
https address of an avatar file of your own, without its extension.
|
|
47
|
+
Falls back to the ``STORK_AVATAR`` environment variable, then ``"a"``.
|
|
48
|
+
**kwargs: Passed to ``FrameProcessor``.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(self, *, avatar: str | None = None, **kwargs):
|
|
52
|
+
"""Initialize the processor.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
avatar: The avatar to draw. See the class description.
|
|
56
|
+
**kwargs: Passed to ``FrameProcessor``.
|
|
57
|
+
"""
|
|
58
|
+
super().__init__(**kwargs)
|
|
59
|
+
self._avatar = _check_avatar(avatar or os.environ.get("STORK_AVATAR") or DEFAULT_AVATAR)
|
|
60
|
+
|
|
61
|
+
@property
|
|
62
|
+
def avatar(self) -> str:
|
|
63
|
+
"""The avatar the client is asked to draw."""
|
|
64
|
+
return self._avatar
|
|
65
|
+
|
|
66
|
+
async def set_avatar(self, avatar: str):
|
|
67
|
+
"""Switch to another avatar and tell the client at once.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
avatar: A library face or the https address of your own avatar file.
|
|
71
|
+
"""
|
|
72
|
+
self._avatar = _check_avatar(avatar)
|
|
73
|
+
await self._announce()
|
|
74
|
+
|
|
75
|
+
async def process_frame(self, frame: Frame, direction: FrameDirection):
|
|
76
|
+
"""Pass every frame through; announce the avatar at the right moments.
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
frame: The frame to process.
|
|
80
|
+
direction: The direction the frame is travelling.
|
|
81
|
+
"""
|
|
82
|
+
await super().process_frame(frame, direction)
|
|
83
|
+
await self.push_frame(frame, direction)
|
|
84
|
+
if isinstance(frame, (ClientConnectedFrame, TTSStartedFrame, BotStartedSpeakingFrame)):
|
|
85
|
+
await self._announce()
|
|
86
|
+
|
|
87
|
+
async def _announce(self):
|
|
88
|
+
await self.push_frame(RTVIServerMessageFrame(data={"type": MESSAGE_TYPE, "avatar": self._avatar}))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def _check_avatar(avatar: str) -> str:
|
|
92
|
+
avatar = avatar.strip()
|
|
93
|
+
if _LIBRARY_NAME.match(avatar):
|
|
94
|
+
return avatar
|
|
95
|
+
if avatar.startswith("https://") and len(avatar) <= 500 and not re.search(r"\s", avatar):
|
|
96
|
+
try:
|
|
97
|
+
url = urlsplit(avatar)
|
|
98
|
+
except ValueError as e:
|
|
99
|
+
raise ValueError(f"the avatar address is not a valid URL: {e}") from e
|
|
100
|
+
if url.query or url.fragment or not url.netloc:
|
|
101
|
+
# the browser adds ".json" and ".bin" to the end of the address
|
|
102
|
+
raise ValueError("the avatar address must not have a query string or fragment")
|
|
103
|
+
return re.sub(r"\.(json|bin)$", "", avatar)
|
|
104
|
+
raise ValueError("avatar must be a Stork library face such as 'a', or the https address of your avatar file")
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
from pipecat.frames.frames import TTSStartedFrame, TextFrame
|
|
5
|
+
from pipecat.processors.frame_processor import FrameDirection
|
|
6
|
+
from pipecat.processors.frameworks.rtvi.frames import RTVIServerMessageFrame
|
|
7
|
+
|
|
8
|
+
from pipecat_stork import MESSAGE_TYPE, StorkLiveAvatar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_avatar_values(monkeypatch):
|
|
12
|
+
monkeypatch.delenv("STORK_AVATAR", raising=False)
|
|
13
|
+
assert StorkLiveAvatar().avatar == "a"
|
|
14
|
+
assert StorkLiveAvatar(avatar="c").avatar == "c"
|
|
15
|
+
assert StorkLiveAvatar(avatar="https://x.example/me.json").avatar == "https://x.example/me"
|
|
16
|
+
monkeypatch.setenv("STORK_AVATAR", "d")
|
|
17
|
+
assert StorkLiveAvatar().avatar == "d"
|
|
18
|
+
for bad in ["http://x.example/me", "A B", "javascript:alert(1)", "https://x.example/me?v=2", "https://[x.example/me"]:
|
|
19
|
+
with pytest.raises(ValueError):
|
|
20
|
+
StorkLiveAvatar(avatar=bad)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_announces_and_passes_frames_through():
|
|
24
|
+
async def run():
|
|
25
|
+
avatar = StorkLiveAvatar(avatar="b")
|
|
26
|
+
pushed = []
|
|
27
|
+
|
|
28
|
+
async def push_frame(frame, direction=FrameDirection.DOWNSTREAM):
|
|
29
|
+
pushed.append(frame)
|
|
30
|
+
|
|
31
|
+
avatar.push_frame = push_frame
|
|
32
|
+
base = type(avatar).__mro__[1].process_frame
|
|
33
|
+
|
|
34
|
+
async def no_super(self, frame, direction):
|
|
35
|
+
return None
|
|
36
|
+
|
|
37
|
+
type(avatar).__mro__[1].process_frame = no_super
|
|
38
|
+
try:
|
|
39
|
+
text = TextFrame("hello")
|
|
40
|
+
await avatar.process_frame(text, FrameDirection.DOWNSTREAM)
|
|
41
|
+
assert pushed == [text]
|
|
42
|
+
started = TTSStartedFrame()
|
|
43
|
+
await avatar.process_frame(started, FrameDirection.DOWNSTREAM)
|
|
44
|
+
assert pushed[1] is started
|
|
45
|
+
assert isinstance(pushed[2], RTVIServerMessageFrame)
|
|
46
|
+
assert pushed[2].data == {"type": MESSAGE_TYPE, "avatar": "b"}
|
|
47
|
+
await avatar.set_avatar("c")
|
|
48
|
+
assert pushed[3].data["avatar"] == "c"
|
|
49
|
+
finally:
|
|
50
|
+
type(avatar).__mro__[1].process_frame = base
|
|
51
|
+
|
|
52
|
+
asyncio.run(run())
|