talksign 0.2.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.
- talksign-0.2.0/.github/workflows/ci.yml +30 -0
- talksign-0.2.0/.gitignore +13 -0
- talksign-0.2.0/CHANGELOG.md +26 -0
- talksign-0.2.0/LICENSE +191 -0
- talksign-0.2.0/PKG-INFO +188 -0
- talksign-0.2.0/README.md +152 -0
- talksign-0.2.0/examples/frames_to_mp4.py +30 -0
- talksign-0.2.0/examples/live_stream.py +32 -0
- talksign-0.2.0/examples/rest_quickstart.py +13 -0
- talksign-0.2.0/pyproject.toml +68 -0
- talksign-0.2.0/src/talksign/__init__.py +57 -0
- talksign-0.2.0/src/talksign/_base.py +244 -0
- talksign-0.2.0/src/talksign/_client.py +240 -0
- talksign-0.2.0/src/talksign/_echo.py +391 -0
- talksign-0.2.0/src/talksign/_errors.py +171 -0
- talksign-0.2.0/src/talksign/_requests.py +309 -0
- talksign-0.2.0/src/talksign/_resources.py +775 -0
- talksign-0.2.0/src/talksign/_splitter.py +124 -0
- talksign-0.2.0/src/talksign/_version.py +1 -0
- talksign-0.2.0/src/talksign/py.typed +0 -0
- talksign-0.2.0/src/talksign/types.py +379 -0
- talksign-0.2.0/src/talksign/video.py +625 -0
- talksign-0.2.0/tests/__init__.py +0 -0
- talksign-0.2.0/tests/conftest.py +65 -0
- talksign-0.2.0/tests/test_client.py +366 -0
- talksign-0.2.0/tests/test_echo.py +173 -0
- talksign-0.2.0/tests/test_splitter.py +60 -0
- talksign-0.2.0/tests/test_v020.py +141 -0
- talksign-0.2.0/tests/test_video.py +221 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python-version }}
|
|
19
|
+
- name: Install ffmpeg
|
|
20
|
+
run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
|
21
|
+
- name: Install
|
|
22
|
+
run: pip install -e ".[video,dev]"
|
|
23
|
+
- name: Lint
|
|
24
|
+
run: |
|
|
25
|
+
ruff check .
|
|
26
|
+
ruff format --check .
|
|
27
|
+
- name: Type check
|
|
28
|
+
run: mypy
|
|
29
|
+
- name: Test
|
|
30
|
+
run: pytest
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
- `EchoFrameSource.aclose()` cancels clip downloads still in flight before closing its HTTP client (no more
|
|
6
|
+
"Task exception was never retrieved" after an interrupt or shutdown); new `ClipCache.aclose()`.
|
|
7
|
+
- `client.tokens.create(expires_in=, allowed_origins=, scopes=)`: short-lived browser tokens (`tst_…`) for web pages.
|
|
8
|
+
- Avatars carry `idle` (signed idle-loop URL); `avatars.list/get` take `language=`.
|
|
9
|
+
- `echo.stream()` fetches the avatar's idle loop at start (one free call; `idle` event with `reason="ready"`), so
|
|
10
|
+
players show the avatar before the first sentence. `fetch_idle=False` turns it off.
|
|
11
|
+
- `echo.stream(chunking="full")`: buffer until flush/close and sign in one call. Default stays `"sentence"`.
|
|
12
|
+
- `echo.stream(first_chunk_chars=40)` (default on): the first piece of a reply may be cut at a comma/clause, so
|
|
13
|
+
signing starts sooner. `SentenceSplitter(first_chunk_chars=...)`.
|
|
14
|
+
- `EchoFrameSource(realtime=False)`: never emits idle/background filler while signing work is pending (offline
|
|
15
|
+
renders were blank when clips were still downloading).
|
|
16
|
+
- `EchoStream.busy`, `EchoStream.wait_idle_fetched()`.
|
|
17
|
+
- LICENSE: removed the duplicated Apache appendix.
|
|
18
|
+
|
|
19
|
+
## 0.1.0 (unreleased)
|
|
20
|
+
|
|
21
|
+
- First release.
|
|
22
|
+
- `Talksign` and `AsyncTalksign` clients for the `/v1` REST API: speech-to-sign (realtime, studio, gloss, video),
|
|
23
|
+
avatars, jobs (with `wait`), uploads, meetings, speech-to-speech, voice, models, warmup, usage and balance.
|
|
24
|
+
- Typed errors, automatic retries with backoff and `Retry-After`, automatic `Idempotency-Key` on POST.
|
|
25
|
+
- `client.echo.stream()`: live Echo 2.0 signing from streamed text (sentence splitter, prefetch, interrupt).
|
|
26
|
+
- `talksign.video.EchoFrameSource` (extra `video`): steady RGB frames for video pipelines and voice-agent plugins.
|
talksign-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Talksign
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
talksign-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: talksign
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Official Python SDK for the Talksign API: speech and text to sign language video.
|
|
5
|
+
Project-URL: Homepage, https://talksign.co
|
|
6
|
+
Project-URL: Documentation, https://github.com/talksign/talksign-python#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/talksign/talksign-python
|
|
8
|
+
Project-URL: Issues, https://github.com/talksign/talksign-python/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/talksign/talksign-python/blob/main/CHANGELOG.md
|
|
10
|
+
Author: Talksign
|
|
11
|
+
License-Expression: Apache-2.0
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: accessibility,api,asl,avatar,bsl,sign language,talksign
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: httpx<1,>=0.25
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
32
|
+
Provides-Extra: video
|
|
33
|
+
Requires-Dist: av>=12; extra == 'video'
|
|
34
|
+
Requires-Dist: numpy>=1.24; extra == 'video'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# Talksign Python SDK
|
|
38
|
+
|
|
39
|
+
The official Python library for the [Talksign](https://talksign.co) API: turn speech or text into
|
|
40
|
+
sign language video with **Echo 2.0**, in a few lines.
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
pip install talksign # REST client + live stream
|
|
44
|
+
pip install "talksign[video]" # + RGB frame decoder for video pipelines (PyAV, numpy)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Python 3.10+. Get an API key (`sk-live-…`) in the [Developer Console](https://developer.talksign.co)
|
|
48
|
+
and set it as `TALKSIGN_API_KEY`.
|
|
49
|
+
|
|
50
|
+
## REST quickstart
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from talksign import Talksign
|
|
54
|
+
|
|
55
|
+
client = Talksign() # reads TALKSIGN_API_KEY
|
|
56
|
+
|
|
57
|
+
res = client.speech_to_sign.realtime("Hello, how are you?", avatar="arthur", language="asl")
|
|
58
|
+
for clip in res["data"]["playlist"]:
|
|
59
|
+
print(clip["gloss"], clip["url"])
|
|
60
|
+
print("cost:", res["usage"]["costUsd"], "USD")
|
|
61
|
+
|
|
62
|
+
# One rendered MP4 instead of a clip playlist
|
|
63
|
+
video = client.speech_to_sign.studio("Welcome to our store", avatar="amara")
|
|
64
|
+
print(video["data"]["download_url"])
|
|
65
|
+
|
|
66
|
+
print(client.balance.retrieve()["available_usd"])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Async: use `AsyncTalksign` — same resources, `await` every call.
|
|
70
|
+
|
|
71
|
+
| Resource | Methods |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `speech_to_sign` | `realtime`, `create`, `studio`, `gloss`, `video` |
|
|
74
|
+
| `avatars` | `list`, `get`, `create`, `delete`, `validate` |
|
|
75
|
+
| `jobs` | `create`, `get`, `list`, `cancel`, `wait` |
|
|
76
|
+
| `speech_to_speech` | `create` |
|
|
77
|
+
| `voice` | `create` (MP3 bytes), `create_json`, `voices` |
|
|
78
|
+
| `sign_to_speech` | `create` (not available in the API yet: raises `APIError` 501) |
|
|
79
|
+
| `uploads`, `meetings` | `create` / `create`, `get`, `stop` |
|
|
80
|
+
| `models` | `list`, `warmup` |
|
|
81
|
+
| `usage`, `balance` | `list`, `retrieve` |
|
|
82
|
+
| client | `openapi()` |
|
|
83
|
+
|
|
84
|
+
Responses are plain `dict`s typed with `TypedDict`s from `talksign.types`.
|
|
85
|
+
|
|
86
|
+
## Live signing from streamed text
|
|
87
|
+
|
|
88
|
+
`client.echo.stream()` turns text as it arrives (LLM tokens, TTS text) into an ordered stream of sign clips.
|
|
89
|
+
It cuts sentences, makes one realtime call per sentence with the next one prefetched, and can be interrupted.
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import asyncio
|
|
93
|
+
from talksign import AsyncTalksign
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
async def main():
|
|
97
|
+
async with AsyncTalksign() as client:
|
|
98
|
+
stream = client.echo.stream(avatar="arthur", language="asl")
|
|
99
|
+
|
|
100
|
+
async def feed():
|
|
101
|
+
for chunk in ["Hi there! ", "How can I ", "help you today?"]:
|
|
102
|
+
stream.push_text(chunk)
|
|
103
|
+
await stream.aclose() # flush the rest, then "done"
|
|
104
|
+
|
|
105
|
+
asyncio.create_task(feed())
|
|
106
|
+
async for event in stream:
|
|
107
|
+
if event.type == "sentence":
|
|
108
|
+
print("signing:", event.text, event.glosses)
|
|
109
|
+
elif event.type == "clip":
|
|
110
|
+
print(" play", event.clip["gloss"], event.clip["url"])
|
|
111
|
+
elif event.type == "idle":
|
|
112
|
+
print("idle loop:", event.idle and event.idle["url"])
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
asyncio.run(main())
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Events: `sentence` (has `glosses`, `usage`, `has_missing`), `clip` (in order; clips without a URL are skipped), `interrupted`, `idle` (`reason`: `ready` = the avatar's idle loop fetched at start with one free
|
|
119
|
+
`GET /v1/avatars/{id}`, so you can show the avatar before the first sentence; `drained`; `interrupt`), `error` (a sentence failed and was
|
|
120
|
+
skipped), `done`. Call `stream.interrupt()` when the user barges in: in-flight calls are aborted and the queue is dropped.
|
|
121
|
+
|
|
122
|
+
Each word's clip plays `in_url` → `url` from `active_start_s` to `active_end_s` → `out_url`; loop the `idle` clip in between.
|
|
123
|
+
|
|
124
|
+
Options of `echo.stream(...)`:
|
|
125
|
+
|
|
126
|
+
- `chunking="sentence"` (default) signs each sentence as soon as it is complete. `chunking="full"` buffers everything
|
|
127
|
+
until `flush()` / close and signs it in one call (fewer calls, later start).
|
|
128
|
+
- `first_chunk_chars=40` (default): the first piece of each reply may be cut at a comma or clause once it has 40
|
|
129
|
+
characters, so the avatar starts sooner. `0` turns it off.
|
|
130
|
+
- `fetch_idle=True` (default): fetch the avatar's idle loop at start (free). `False` skips it.
|
|
131
|
+
|
|
132
|
+
## Avatars and their idle loop
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
avatar = client.avatars.get("arthur") # free
|
|
136
|
+
idle = avatar["data"]["idle"] # {"url": ..., "expires_at": ...} or None
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Every avatar from `avatars.list()` / `avatars.get()` carries `idle`, a short-lived signed URL of its idle loop.
|
|
140
|
+
|
|
141
|
+
## Browser apps: short-lived tokens
|
|
142
|
+
|
|
143
|
+
Never put your secret key in a web page. Mint a short-lived token on your server and hand it to the page:
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
token = client.tokens.create(expires_in=600, allowed_origins=["https://app.example.com"])
|
|
147
|
+
# -> {"token": "tst_…", "expires_at": "…", "scopes": ["sign:realtime", "avatars:read"], ...}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The token can only call `POST /v1/speech-to-sign/realtime` and `GET /v1/avatars[/{id}]`, bills your wallet like the
|
|
151
|
+
key, and ends when the key is revoked. Set `allowed_origins` in production. In the page, use the JavaScript SDK
|
|
152
|
+
(`new Talksign({ token })`).
|
|
153
|
+
|
|
154
|
+
## Video frames (for video pipelines and agent plugins)
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from talksign import AsyncTalksign
|
|
158
|
+
from talksign.video import EchoFrameSource
|
|
159
|
+
|
|
160
|
+
source = EchoFrameSource.from_client(AsyncTalksign(), avatar="arthur", width=1280, height=720, fps=30)
|
|
161
|
+
source.push_text("Nice to meet you.")
|
|
162
|
+
async for frame in source: # numpy uint8 array (720, 1280, 3), RGB, at 30 FPS
|
|
163
|
+
publish(frame)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
It loops the idle clip while nothing is signing, crossfades between clips (150 ms), downloads clips with bounded
|
|
167
|
+
concurrency and an LRU cache, and decodes in a worker thread. `source.interrupt()` returns to idle at once.
|
|
168
|
+
The idle loop is fetched at start (free), so the avatar is visible from the first frame. With `realtime=False`
|
|
169
|
+
(offline rendering) frames are produced as fast as possible and never padded with idle/background frames while a
|
|
170
|
+
sentence is still being fetched or downloaded.
|
|
171
|
+
|
|
172
|
+
## Errors and retries
|
|
173
|
+
|
|
174
|
+
All errors derive from `talksign.TalksignError` and carry `status_code`, `code`, `param` and `request_id`:
|
|
175
|
+
`APIError` (any HTTP error; base of) `AuthenticationError` (401), `InsufficientBalanceError` (402), `PermissionDeniedError` (403), `NotFoundError` (404),
|
|
176
|
+
`BadRequestError` (400/409/413/422), `RateLimitError` (429, `retry_after`), plus `APIConnectionError` / `APITimeoutError`. `status` is an alias of `status_code`.
|
|
177
|
+
|
|
178
|
+
429, 5xx and network errors are retried `max_retries` times (default 2) with exponential backoff, honouring `Retry-After`.
|
|
179
|
+
Every POST carries an `Idempotency-Key` (reused across retries), so a retried call is never charged twice. Pass your own
|
|
180
|
+
with `idempotency_key=`.
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
client = Talksign(api_key="sk-live-…", base_url="https://api.talksign.co", timeout=30, max_retries=3)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Licence
|
|
187
|
+
|
|
188
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
talksign-0.2.0/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Talksign Python SDK
|
|
2
|
+
|
|
3
|
+
The official Python library for the [Talksign](https://talksign.co) API: turn speech or text into
|
|
4
|
+
sign language video with **Echo 2.0**, in a few lines.
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
pip install talksign # REST client + live stream
|
|
8
|
+
pip install "talksign[video]" # + RGB frame decoder for video pipelines (PyAV, numpy)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Python 3.10+. Get an API key (`sk-live-…`) in the [Developer Console](https://developer.talksign.co)
|
|
12
|
+
and set it as `TALKSIGN_API_KEY`.
|
|
13
|
+
|
|
14
|
+
## REST quickstart
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from talksign import Talksign
|
|
18
|
+
|
|
19
|
+
client = Talksign() # reads TALKSIGN_API_KEY
|
|
20
|
+
|
|
21
|
+
res = client.speech_to_sign.realtime("Hello, how are you?", avatar="arthur", language="asl")
|
|
22
|
+
for clip in res["data"]["playlist"]:
|
|
23
|
+
print(clip["gloss"], clip["url"])
|
|
24
|
+
print("cost:", res["usage"]["costUsd"], "USD")
|
|
25
|
+
|
|
26
|
+
# One rendered MP4 instead of a clip playlist
|
|
27
|
+
video = client.speech_to_sign.studio("Welcome to our store", avatar="amara")
|
|
28
|
+
print(video["data"]["download_url"])
|
|
29
|
+
|
|
30
|
+
print(client.balance.retrieve()["available_usd"])
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Async: use `AsyncTalksign` — same resources, `await` every call.
|
|
34
|
+
|
|
35
|
+
| Resource | Methods |
|
|
36
|
+
|---|---|
|
|
37
|
+
| `speech_to_sign` | `realtime`, `create`, `studio`, `gloss`, `video` |
|
|
38
|
+
| `avatars` | `list`, `get`, `create`, `delete`, `validate` |
|
|
39
|
+
| `jobs` | `create`, `get`, `list`, `cancel`, `wait` |
|
|
40
|
+
| `speech_to_speech` | `create` |
|
|
41
|
+
| `voice` | `create` (MP3 bytes), `create_json`, `voices` |
|
|
42
|
+
| `sign_to_speech` | `create` (not available in the API yet: raises `APIError` 501) |
|
|
43
|
+
| `uploads`, `meetings` | `create` / `create`, `get`, `stop` |
|
|
44
|
+
| `models` | `list`, `warmup` |
|
|
45
|
+
| `usage`, `balance` | `list`, `retrieve` |
|
|
46
|
+
| client | `openapi()` |
|
|
47
|
+
|
|
48
|
+
Responses are plain `dict`s typed with `TypedDict`s from `talksign.types`.
|
|
49
|
+
|
|
50
|
+
## Live signing from streamed text
|
|
51
|
+
|
|
52
|
+
`client.echo.stream()` turns text as it arrives (LLM tokens, TTS text) into an ordered stream of sign clips.
|
|
53
|
+
It cuts sentences, makes one realtime call per sentence with the next one prefetched, and can be interrupted.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import asyncio
|
|
57
|
+
from talksign import AsyncTalksign
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
async def main():
|
|
61
|
+
async with AsyncTalksign() as client:
|
|
62
|
+
stream = client.echo.stream(avatar="arthur", language="asl")
|
|
63
|
+
|
|
64
|
+
async def feed():
|
|
65
|
+
for chunk in ["Hi there! ", "How can I ", "help you today?"]:
|
|
66
|
+
stream.push_text(chunk)
|
|
67
|
+
await stream.aclose() # flush the rest, then "done"
|
|
68
|
+
|
|
69
|
+
asyncio.create_task(feed())
|
|
70
|
+
async for event in stream:
|
|
71
|
+
if event.type == "sentence":
|
|
72
|
+
print("signing:", event.text, event.glosses)
|
|
73
|
+
elif event.type == "clip":
|
|
74
|
+
print(" play", event.clip["gloss"], event.clip["url"])
|
|
75
|
+
elif event.type == "idle":
|
|
76
|
+
print("idle loop:", event.idle and event.idle["url"])
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
asyncio.run(main())
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Events: `sentence` (has `glosses`, `usage`, `has_missing`), `clip` (in order; clips without a URL are skipped), `interrupted`, `idle` (`reason`: `ready` = the avatar's idle loop fetched at start with one free
|
|
83
|
+
`GET /v1/avatars/{id}`, so you can show the avatar before the first sentence; `drained`; `interrupt`), `error` (a sentence failed and was
|
|
84
|
+
skipped), `done`. Call `stream.interrupt()` when the user barges in: in-flight calls are aborted and the queue is dropped.
|
|
85
|
+
|
|
86
|
+
Each word's clip plays `in_url` → `url` from `active_start_s` to `active_end_s` → `out_url`; loop the `idle` clip in between.
|
|
87
|
+
|
|
88
|
+
Options of `echo.stream(...)`:
|
|
89
|
+
|
|
90
|
+
- `chunking="sentence"` (default) signs each sentence as soon as it is complete. `chunking="full"` buffers everything
|
|
91
|
+
until `flush()` / close and signs it in one call (fewer calls, later start).
|
|
92
|
+
- `first_chunk_chars=40` (default): the first piece of each reply may be cut at a comma or clause once it has 40
|
|
93
|
+
characters, so the avatar starts sooner. `0` turns it off.
|
|
94
|
+
- `fetch_idle=True` (default): fetch the avatar's idle loop at start (free). `False` skips it.
|
|
95
|
+
|
|
96
|
+
## Avatars and their idle loop
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
avatar = client.avatars.get("arthur") # free
|
|
100
|
+
idle = avatar["data"]["idle"] # {"url": ..., "expires_at": ...} or None
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Every avatar from `avatars.list()` / `avatars.get()` carries `idle`, a short-lived signed URL of its idle loop.
|
|
104
|
+
|
|
105
|
+
## Browser apps: short-lived tokens
|
|
106
|
+
|
|
107
|
+
Never put your secret key in a web page. Mint a short-lived token on your server and hand it to the page:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
token = client.tokens.create(expires_in=600, allowed_origins=["https://app.example.com"])
|
|
111
|
+
# -> {"token": "tst_…", "expires_at": "…", "scopes": ["sign:realtime", "avatars:read"], ...}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The token can only call `POST /v1/speech-to-sign/realtime` and `GET /v1/avatars[/{id}]`, bills your wallet like the
|
|
115
|
+
key, and ends when the key is revoked. Set `allowed_origins` in production. In the page, use the JavaScript SDK
|
|
116
|
+
(`new Talksign({ token })`).
|
|
117
|
+
|
|
118
|
+
## Video frames (for video pipelines and agent plugins)
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from talksign import AsyncTalksign
|
|
122
|
+
from talksign.video import EchoFrameSource
|
|
123
|
+
|
|
124
|
+
source = EchoFrameSource.from_client(AsyncTalksign(), avatar="arthur", width=1280, height=720, fps=30)
|
|
125
|
+
source.push_text("Nice to meet you.")
|
|
126
|
+
async for frame in source: # numpy uint8 array (720, 1280, 3), RGB, at 30 FPS
|
|
127
|
+
publish(frame)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
It loops the idle clip while nothing is signing, crossfades between clips (150 ms), downloads clips with bounded
|
|
131
|
+
concurrency and an LRU cache, and decodes in a worker thread. `source.interrupt()` returns to idle at once.
|
|
132
|
+
The idle loop is fetched at start (free), so the avatar is visible from the first frame. With `realtime=False`
|
|
133
|
+
(offline rendering) frames are produced as fast as possible and never padded with idle/background frames while a
|
|
134
|
+
sentence is still being fetched or downloaded.
|
|
135
|
+
|
|
136
|
+
## Errors and retries
|
|
137
|
+
|
|
138
|
+
All errors derive from `talksign.TalksignError` and carry `status_code`, `code`, `param` and `request_id`:
|
|
139
|
+
`APIError` (any HTTP error; base of) `AuthenticationError` (401), `InsufficientBalanceError` (402), `PermissionDeniedError` (403), `NotFoundError` (404),
|
|
140
|
+
`BadRequestError` (400/409/413/422), `RateLimitError` (429, `retry_after`), plus `APIConnectionError` / `APITimeoutError`. `status` is an alias of `status_code`.
|
|
141
|
+
|
|
142
|
+
429, 5xx and network errors are retried `max_retries` times (default 2) with exponential backoff, honouring `Retry-After`.
|
|
143
|
+
Every POST carries an `Idempotency-Key` (reused across retries), so a retried call is never charged twice. Pass your own
|
|
144
|
+
with `idempotency_key=`.
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
client = Talksign(api_key="sk-live-…", base_url="https://api.talksign.co", timeout=30, max_retries=3)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Licence
|
|
151
|
+
|
|
152
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Records 6 seconds of EchoFrameSource output to out.mp4. Needs talksign[video] and TALKSIGN_API_KEY."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
import av
|
|
6
|
+
|
|
7
|
+
from talksign import AsyncTalksign
|
|
8
|
+
from talksign.video import EchoFrameSource
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
async def main() -> None:
|
|
12
|
+
async with AsyncTalksign() as client:
|
|
13
|
+
source = EchoFrameSource.from_client(client, avatar="arthur", width=640, height=360, fps=30)
|
|
14
|
+
source.push_text("Welcome to Talksign. Nice to meet you.")
|
|
15
|
+
with av.open("out.mp4", "w") as out:
|
|
16
|
+
stream = out.add_stream("libx264", rate=30)
|
|
17
|
+
stream.width, stream.height, stream.pix_fmt = 640, 360, "yuv420p"
|
|
18
|
+
n = 0
|
|
19
|
+
async for frame in source:
|
|
20
|
+
for packet in stream.encode(av.VideoFrame.from_ndarray(frame, format="rgb24")):
|
|
21
|
+
out.mux(packet)
|
|
22
|
+
n += 1
|
|
23
|
+
if n >= 180:
|
|
24
|
+
break
|
|
25
|
+
for packet in stream.encode():
|
|
26
|
+
out.mux(packet)
|
|
27
|
+
await source.aclose()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Live signing of streamed text (e.g. LLM tokens). Needs TALKSIGN_API_KEY (calls are billed)."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from talksign import AsyncTalksign
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async def main() -> None:
|
|
9
|
+
async with AsyncTalksign() as client:
|
|
10
|
+
await client.models.warmup()
|
|
11
|
+
stream = client.echo.stream(avatar="arthur", language="asl")
|
|
12
|
+
|
|
13
|
+
async def agent_tokens() -> None:
|
|
14
|
+
for token in "Hi there! I can help you book a table. What time works for you?".split(" "):
|
|
15
|
+
stream.push_text(token + " ")
|
|
16
|
+
await asyncio.sleep(0.05)
|
|
17
|
+
await stream.aclose()
|
|
18
|
+
|
|
19
|
+
task = asyncio.create_task(agent_tokens())
|
|
20
|
+
async for event in stream:
|
|
21
|
+
if event.type == "sentence":
|
|
22
|
+
print("signing:", event.text, event.glosses)
|
|
23
|
+
elif event.type == "clip":
|
|
24
|
+
print(" clip:", event.clip["gloss"])
|
|
25
|
+
elif event.type == "error":
|
|
26
|
+
print(" error:", event.error)
|
|
27
|
+
elif event.type == "idle":
|
|
28
|
+
print(" idle")
|
|
29
|
+
await task
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
asyncio.run(main())
|