vision-agents-plugins-talksign 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ .pytest_cache/
8
+ .mypy_cache/
9
+ .ruff_cache/
10
+ .coverage
11
+ htmlcov/
12
+ .env
13
+ *.mp4
@@ -0,0 +1,202 @@
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
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Talksign
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.5
2
+ Name: vision-agents-plugins-talksign
3
+ Version: 0.1.0
4
+ Summary: Talksign sign language avatar plugin for Vision Agents
5
+ Project-URL: Homepage, https://talksign.co
6
+ Project-URL: Documentation, https://github.com/talksign/vision-agents-talksign#readme
7
+ Project-URL: Repository, https://github.com/talksign/vision-agents-talksign
8
+ Project-URL: Issues, https://github.com/talksign/vision-agents-talksign/issues
9
+ Project-URL: Changelog, https://github.com/talksign/vision-agents-talksign/blob/main/CHANGELOG.md
10
+ Author: Talksign
11
+ License-Expression: Apache-2.0
12
+ License-File: LICENSE
13
+ Keywords: AI,agents,asl,avatars,sign language,talksign,voice agents
14
+ Requires-Python: >=3.10
15
+ Requires-Dist: talksign[video]>=0.2.0
16
+ Requires-Dist: vision-agents<0.7,>=0.6.9
17
+ Provides-Extra: dev
18
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
19
+ Requires-Dist: pytest>=8; extra == 'dev'
20
+ Requires-Dist: respx>=0.21; extra == 'dev'
21
+ Requires-Dist: ruff>=0.6; extra == 'dev'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Talksign Avatar Plugin for Vision Agents
25
+
26
+ A [Talksign](https://talksign.co) sign language avatar for [Vision Agents](https://visionagents.ai/):
27
+ an **Echo 2.0** avatar signs your agent's replies in ASL, while the agent's voice still plays.
28
+
29
+ ```bash
30
+ pip install vision-agents-plugins-talksign # then: Agent(..., processors=[talksign.TalksignAvatarPublisher()])
31
+ ```
32
+
33
+ ## Features
34
+
35
+ - The agent's outbound video becomes the signing avatar (1280x720, 30 FPS by default), with an idle loop between answers
36
+ - Signs exactly what the TTS speaks (`TTSSynthesisStartEvent`); final LLM text for realtime LLMs without TTS
37
+ - Voice is untouched: works next to any TTS provider or realtime LLM
38
+ - Stops signing and returns to idle when the user barges in
39
+ - Sign → text (Palm) is coming soon
40
+
41
+ ## Quick Start
42
+
43
+ ```python
44
+ from vision_agents.core import Agent, User
45
+ from vision_agents.plugins import deepgram, elevenlabs, gemini, getstream, talksign
46
+
47
+ agent = Agent(
48
+ edge=getstream.Edge(),
49
+ agent_user=User(name="Signing Assistant", id="agent"),
50
+ instructions="You're a friendly assistant.",
51
+ llm=gemini.LLM(),
52
+ tts=elevenlabs.TTS(),
53
+ stt=deepgram.STT(),
54
+ processors=[talksign.TalksignAvatarPublisher(avatar="arthur", language="asl")],
55
+ )
56
+ ```
57
+
58
+ Full example: [`examples/signing_agent.py`](examples/signing_agent.py).
59
+
60
+ ## Configuration
61
+
62
+ ```bash
63
+ TALKSIGN_API_KEY=your_talksign_api_key # from https://developer.talksign.co
64
+ ```
65
+
66
+ ```python
67
+ talksign.TalksignAvatarPublisher(
68
+ avatar="arthur", # Talksign avatar id
69
+ language="asl", # sign language
70
+ api_key=None, # or TALKSIGN_API_KEY
71
+ width=1280,
72
+ height=720,
73
+ fps=30,
74
+ text_source="auto", # "tts" | "llm" | "auto" (TTS when the agent has one)
75
+ client=None, # reuse a talksign.AsyncTalksign
76
+ source_options=None, # extra talksign.video.EchoFrameSource options
77
+ )
78
+ ```
79
+
80
+ ## Requirements
81
+
82
+ - Python 3.10+, Vision Agents 0.6.9+ (tested with 0.6.9)
83
+ - Talksign API key; Stream account for video calls
84
+
85
+ ## Development
86
+
87
+ ```bash
88
+ pip install -e ../talksign-python[video] -e ".[dev]"
89
+ pytest # offline: a fake Talksign API, fake edge/LLM/TTS, the real Agent
90
+ ```
91
+
92
+ ## License
93
+
94
+ Apache-2.0
@@ -0,0 +1,71 @@
1
+ # Talksign Avatar Plugin for Vision Agents
2
+
3
+ A [Talksign](https://talksign.co) sign language avatar for [Vision Agents](https://visionagents.ai/):
4
+ an **Echo 2.0** avatar signs your agent's replies in ASL, while the agent's voice still plays.
5
+
6
+ ```bash
7
+ pip install vision-agents-plugins-talksign # then: Agent(..., processors=[talksign.TalksignAvatarPublisher()])
8
+ ```
9
+
10
+ ## Features
11
+
12
+ - The agent's outbound video becomes the signing avatar (1280x720, 30 FPS by default), with an idle loop between answers
13
+ - Signs exactly what the TTS speaks (`TTSSynthesisStartEvent`); final LLM text for realtime LLMs without TTS
14
+ - Voice is untouched: works next to any TTS provider or realtime LLM
15
+ - Stops signing and returns to idle when the user barges in
16
+ - Sign → text (Palm) is coming soon
17
+
18
+ ## Quick Start
19
+
20
+ ```python
21
+ from vision_agents.core import Agent, User
22
+ from vision_agents.plugins import deepgram, elevenlabs, gemini, getstream, talksign
23
+
24
+ agent = Agent(
25
+ edge=getstream.Edge(),
26
+ agent_user=User(name="Signing Assistant", id="agent"),
27
+ instructions="You're a friendly assistant.",
28
+ llm=gemini.LLM(),
29
+ tts=elevenlabs.TTS(),
30
+ stt=deepgram.STT(),
31
+ processors=[talksign.TalksignAvatarPublisher(avatar="arthur", language="asl")],
32
+ )
33
+ ```
34
+
35
+ Full example: [`examples/signing_agent.py`](examples/signing_agent.py).
36
+
37
+ ## Configuration
38
+
39
+ ```bash
40
+ TALKSIGN_API_KEY=your_talksign_api_key # from https://developer.talksign.co
41
+ ```
42
+
43
+ ```python
44
+ talksign.TalksignAvatarPublisher(
45
+ avatar="arthur", # Talksign avatar id
46
+ language="asl", # sign language
47
+ api_key=None, # or TALKSIGN_API_KEY
48
+ width=1280,
49
+ height=720,
50
+ fps=30,
51
+ text_source="auto", # "tts" | "llm" | "auto" (TTS when the agent has one)
52
+ client=None, # reuse a talksign.AsyncTalksign
53
+ source_options=None, # extra talksign.video.EchoFrameSource options
54
+ )
55
+ ```
56
+
57
+ ## Requirements
58
+
59
+ - Python 3.10+, Vision Agents 0.6.9+ (tested with 0.6.9)
60
+ - Talksign API key; Stream account for video calls
61
+
62
+ ## Development
63
+
64
+ ```bash
65
+ pip install -e ../talksign-python[video] -e ".[dev]"
66
+ pytest # offline: a fake Talksign API, fake edge/LLM/TTS, the real Agent
67
+ ```
68
+
69
+ ## License
70
+
71
+ Apache-2.0
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "vision-agents-plugins-talksign"
7
+ dynamic = ["version"]
8
+ description = "Talksign sign language avatar plugin for Vision Agents"
9
+ readme = "README.md"
10
+ keywords = ["talksign", "sign language", "asl", "avatars", "AI", "voice agents", "agents"]
11
+ requires-python = ">=3.10"
12
+ license = "Apache-2.0"
13
+ license-files = ["LICENSE"]
14
+ authors = [{ name = "Talksign" }]
15
+ dependencies = ["vision-agents>=0.6.9,<0.7", "talksign[video]>=0.2.0"]
16
+
17
+ [project.optional-dependencies]
18
+ dev = ["pytest>=8", "pytest-asyncio>=0.23", "respx>=0.21", "ruff>=0.6"]
19
+
20
+ [project.urls]
21
+ Homepage = "https://talksign.co"
22
+ Documentation = "https://github.com/talksign/vision-agents-talksign#readme"
23
+ Repository = "https://github.com/talksign/vision-agents-talksign"
24
+ Issues = "https://github.com/talksign/vision-agents-talksign/issues"
25
+ Changelog = "https://github.com/talksign/vision-agents-talksign/blob/main/CHANGELOG.md"
26
+
27
+ [tool.hatch.version]
28
+ path = "vision_agents/plugins/talksign/__init__.py"
29
+
30
+ [tool.hatch.build.targets.wheel]
31
+ packages = ["vision_agents"]
32
+
33
+ [tool.hatch.build.targets.sdist]
34
+ include = ["/vision_agents"]
35
+
36
+ [tool.pytest.ini_options]
37
+ asyncio_mode = "auto"
38
+ asyncio_default_fixture_loop_scope = "function"
39
+ testpaths = ["tests"]
40
+ addopts = "-q"
41
+
42
+ [tool.ruff]
43
+ line-length = 100
44
+ target-version = "py310"
45
+
46
+ [tool.ruff.lint]
47
+ select = ["E", "F", "W", "I", "B", "UP"]
@@ -0,0 +1,9 @@
1
+ # Copyright 2026 Talksign
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Talksign sign language avatar plugin for Vision Agents."""
4
+
5
+ from .talksign_avatar_publisher import TalksignAvatarPublisher
6
+
7
+ __version__ = "0.1.0"
8
+
9
+ __all__ = ["TalksignAvatarPublisher", "__version__"]
@@ -0,0 +1,175 @@
1
+ # Copyright 2026 Talksign
2
+ # SPDX-License-Identifier: Apache-2.0
3
+ """Talksign avatar publisher: an Echo 2.0 avatar that signs the agent's replies."""
4
+
5
+ import asyncio
6
+ import contextlib
7
+ import logging
8
+ from typing import TYPE_CHECKING, Any, Literal
9
+
10
+ import av
11
+ from vision_agents.core.agents.events import AgentTurnEndedEvent, UserTurnStartedEvent
12
+ from vision_agents.core.llm.events import LLMResponseFinalEvent
13
+ from vision_agents.core.processors import VideoPublisher
14
+ from vision_agents.core.tts.events import TTSSynthesisStartEvent
15
+ from vision_agents.core.utils.video_track import QueuedVideoTrack
16
+
17
+ from talksign import AsyncTalksign
18
+ from talksign.video import EchoFrameSource
19
+
20
+ if TYPE_CHECKING:
21
+ from vision_agents.core import Agent
22
+
23
+ logger = logging.getLogger(__name__)
24
+
25
+ TextSource = Literal["auto", "tts", "llm"]
26
+
27
+
28
+ class TalksignAvatarPublisher(VideoPublisher):
29
+ """Publishes a Talksign Echo 2.0 avatar that signs the agent's replies.
30
+
31
+ Add it as a processor: ``Agent(..., processors=[TalksignAvatarPublisher()])``.
32
+ The agent's outbound video becomes the signing avatar (idle loop between answers);
33
+ the agent's voice is untouched. Text comes from ``TTSSynthesisStartEvent`` (what the
34
+ TTS is about to speak), or from ``LLMResponseFinalEvent`` for realtime LLMs without TTS.
35
+ When the user barges in (user turn starts, or the agent turn ends interrupted), signing
36
+ stops at once and the avatar returns to idle.
37
+ """
38
+
39
+ name = "talksign_avatar"
40
+
41
+ def __init__(
42
+ self,
43
+ avatar: str = "arthur",
44
+ language: str = "asl",
45
+ api_key: str | None = None,
46
+ base_url: str | None = None,
47
+ width: int = 1280,
48
+ height: int = 720,
49
+ fps: int = 30,
50
+ text_source: TextSource = "auto",
51
+ client: AsyncTalksign | None = None,
52
+ source_options: dict[str, Any] | None = None,
53
+ ):
54
+ """Initialize the Talksign avatar publisher.
55
+
56
+ Args:
57
+ avatar: Talksign avatar id, e.g. ``"arthur"``.
58
+ language: Sign language, e.g. ``"asl"``.
59
+ api_key: Talksign API key. Uses the TALKSIGN_API_KEY env var if not provided.
60
+ base_url: Talksign API base URL. Uses TALKSIGN_BASE_URL or the public API.
61
+ width: Output video width in pixels (even).
62
+ height: Output video height in pixels (even).
63
+ fps: Output video frame rate.
64
+ text_source: ``"tts"`` signs the text sent to TTS, ``"llm"`` signs final LLM
65
+ responses, ``"auto"`` uses TTS when the agent has one, else the LLM.
66
+ client: An existing ``talksign.AsyncTalksign`` client (not closed by the publisher).
67
+ source_options: Extra ``talksign.video.EchoFrameSource`` options.
68
+ """
69
+ super().__init__()
70
+ if text_source not in ("auto", "tts", "llm"):
71
+ raise ValueError('text_source must be "auto", "tts" or "llm"')
72
+ self.avatar = avatar
73
+ self.language = language
74
+ self.width = int(width)
75
+ self.height = int(height)
76
+ self.fps = int(fps)
77
+ self.text_source: TextSource = text_source
78
+ self._own_client = client is None
79
+ self._client = client or AsyncTalksign(api_key=api_key, base_url=base_url)
80
+ self._source_options = dict(source_options or {})
81
+ self._track = QueuedVideoTrack(
82
+ width=self.width, height=self.height, fps=self.fps, max_queue_size=self.fps
83
+ )
84
+ self._source: EchoFrameSource | None = None
85
+ self._video_task: asyncio.Task[None] | None = None
86
+ self._closed = False
87
+
88
+ @property
89
+ def is_signing(self) -> bool:
90
+ """True while a sign is playing or queued."""
91
+ return self._source is not None and self._source.is_signing
92
+
93
+ def publish_video_track(self) -> QueuedVideoTrack:
94
+ """Return the video track with the signing avatar."""
95
+ return self._track
96
+
97
+ def attach_agent(self, agent: "Agent") -> None:
98
+ """Listen to the agent's speech text and turn events."""
99
+ source = self.text_source
100
+ if source == "auto":
101
+ source = "tts" if agent.tts is not None else "llm"
102
+
103
+ if source == "tts":
104
+
105
+ @agent.events.subscribe
106
+ async def _on_tts_text(event: TTSSynthesisStartEvent):
107
+ self._sign(event.text)
108
+
109
+ else:
110
+
111
+ @agent.events.subscribe
112
+ async def _on_llm_text(event: LLMResponseFinalEvent):
113
+ self._sign(event.text)
114
+
115
+ @agent.events.subscribe
116
+ async def _on_barge_in(event: UserTurnStartedEvent | AgentTurnEndedEvent):
117
+ # The user starting to talk is a barge-in (the agent interrupts itself on it);
118
+ # realtime LLMs also report an interrupted agent turn.
119
+ if isinstance(event, UserTurnStartedEvent) or event.interrupted:
120
+ self.interrupt()
121
+
122
+ def _sign(self, text: str | None) -> None:
123
+ if self._source is None or self._closed or not text or not text.strip():
124
+ return
125
+ self._source.push_text(text if text[-1:].isspace() else text + " ")
126
+ self._source.flush()
127
+
128
+ def interrupt(self) -> None:
129
+ """Stop signing now and return to the idle loop."""
130
+ if self._source is not None:
131
+ self._source.interrupt()
132
+
133
+ async def start(self) -> None:
134
+ """Open the Echo stream and start publishing frames. Called by the Agent on join."""
135
+ if self._source is not None or self._closed:
136
+ return
137
+ self._source = EchoFrameSource.from_client(
138
+ self._client,
139
+ avatar=self.avatar,
140
+ language=self.language,
141
+ width=self.width,
142
+ height=self.height,
143
+ fps=self.fps,
144
+ **self._source_options,
145
+ )
146
+ self._video_task = asyncio.create_task(self._run(), name="talksign_avatar_video")
147
+
148
+ async def _run(self) -> None:
149
+ assert self._source is not None
150
+ try:
151
+ async for image in self._source:
152
+ await self._track.add_frame(av.VideoFrame.from_ndarray(image, format="rgb24"))
153
+ except asyncio.CancelledError:
154
+ raise
155
+ except Exception:
156
+ logger.exception("Talksign avatar video stopped")
157
+
158
+ async def close(self) -> None:
159
+ """Stop the video, close the Echo stream and release resources."""
160
+ if self._closed:
161
+ return
162
+ self._closed = True
163
+ if self._video_task is not None:
164
+ self._video_task.cancel()
165
+ with contextlib.suppress(asyncio.CancelledError):
166
+ await self._video_task
167
+ self._video_task = None
168
+ if self._source is not None:
169
+ with contextlib.suppress(Exception):
170
+ await self._source.aclose()
171
+ self._source = None
172
+ self._track.stop()
173
+ if self._own_client:
174
+ with contextlib.suppress(Exception):
175
+ await self._client.aclose()