vis-agent 0.5.22.dev9332__py3-none-any.whl → 0.5.22.dev9358__py3-none-any.whl
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.
- blockether/vis/_contracts.py +1 -0
- blockether/vis/_data/fixtures/gateway-answers.json +198 -0
- blockether/vis/_data/schema/content.json +68 -0
- blockether/vis/_data/schema/gateway.json +831 -2
- blockether/vis/_data/schema/voice.json +737 -0
- blockether/vis/_outside.py +1 -1
- blockether/vis/engine/__init__.py +5 -4
- blockether/vis/engine/_agent.py +34 -17
- blockether/vis/engine/_client.py +72 -2585
- blockether/vis/engine/_extensions.py +3 -3
- blockether/vis/engine/_groups.py +1 -1
- blockether/vis/engine/_host.py +4 -4
- blockether/vis/engine/_local.py +8 -8
- blockether/vis/engine/_routes.py +2662 -0
- blockether/vis/engine/_sounds.py +11 -9
- blockether/vis/engine/_speech.py +18 -16
- blockether/vis/engine/_types.py +385 -40
- blockether/vis/engine/release-tag +1 -1
- blockether/vis/extension.py +7 -11
- {vis_agent-0.5.22.dev9332.dist-info → vis_agent-0.5.22.dev9358.dist-info}/METADATA +1 -1
- {vis_agent-0.5.22.dev9332.dist-info → vis_agent-0.5.22.dev9358.dist-info}/RECORD +23 -21
- {vis_agent-0.5.22.dev9332.dist-info → vis_agent-0.5.22.dev9358.dist-info}/WHEEL +0 -0
- {vis_agent-0.5.22.dev9332.dist-info → vis_agent-0.5.22.dev9358.dist-info}/licenses/LICENSE +0 -0
blockether/vis/engine/_sounds.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Sounds API: the sounds that the gateway machine plays for your turns.
|
|
2
2
|
|
|
3
|
-
Use `
|
|
3
|
+
Use `EngineClient.sounds` from the SDK, or `vis.sounds` inside an extension. Both
|
|
4
4
|
change the same machine settings that Settings > Sounds shows in the Companion app and
|
|
5
5
|
the TUI, so a change from one place shows in all of them.
|
|
6
6
|
|
|
@@ -20,7 +20,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
20
20
|
from ._client import ProtocolError
|
|
21
21
|
|
|
22
22
|
if TYPE_CHECKING:
|
|
23
|
-
from ._client import
|
|
23
|
+
from ._client import EngineClient
|
|
24
24
|
|
|
25
25
|
SLOTS = ("finish", "input", "error")
|
|
26
26
|
"""The slots of a preset, in the order that settings show them."""
|
|
@@ -116,13 +116,15 @@ def _custom_wire(preset: SoundPreset) -> dict[str, Any]:
|
|
|
116
116
|
class Sounds:
|
|
117
117
|
"""Read and change the sounds that the gateway machine plays."""
|
|
118
118
|
|
|
119
|
-
def __init__(self,
|
|
120
|
-
self.
|
|
119
|
+
def __init__(self, client: EngineClient):
|
|
120
|
+
self._client = client
|
|
121
121
|
|
|
122
122
|
def get(self) -> SoundSettings:
|
|
123
123
|
"""Return the current sound settings with every preset."""
|
|
124
|
-
enabled = _row(
|
|
125
|
-
|
|
124
|
+
enabled = _row(
|
|
125
|
+
self._client.routes.get_setting(_ENABLED, query=_GLOBAL), _ENABLED
|
|
126
|
+
)
|
|
127
|
+
row = _row(self._client.routes.get_setting(_PRESETS, query=_GLOBAL), _PRESETS)
|
|
126
128
|
value = row.get("value")
|
|
127
129
|
options = row.get("editor_options")
|
|
128
130
|
if not isinstance(value, dict) or not isinstance(options, dict):
|
|
@@ -168,7 +170,7 @@ class Sounds:
|
|
|
168
170
|
if chosen is None:
|
|
169
171
|
raise ValueError(f"no preset is called {preset.strip()}")
|
|
170
172
|
if enabled is not _UNSET:
|
|
171
|
-
self.
|
|
173
|
+
self._client.routes.post_settings(
|
|
172
174
|
body={**_GLOBAL, "id": _ENABLED, "action": "value", "value": enabled}
|
|
173
175
|
)
|
|
174
176
|
if current is not None and chosen is not None:
|
|
@@ -232,7 +234,7 @@ class Sounds:
|
|
|
232
234
|
"""
|
|
233
235
|
if slot not in SLOTS:
|
|
234
236
|
raise ValueError(f"slot must be one of {', '.join(SLOTS)}")
|
|
235
|
-
reply = self.
|
|
237
|
+
reply = self._client.routes.post_setting_preview(
|
|
236
238
|
_PRESETS, body={"slot": slot, "value": _slot_value(slot, value)}
|
|
237
239
|
)
|
|
238
240
|
played = reply.get("is_played") if isinstance(reply, dict) else None
|
|
@@ -241,7 +243,7 @@ class Sounds:
|
|
|
241
243
|
return played
|
|
242
244
|
|
|
243
245
|
def _write(self, active: str, custom: tuple[SoundPreset, ...]) -> None:
|
|
244
|
-
self.
|
|
246
|
+
self._client.routes.post_settings(
|
|
245
247
|
body={
|
|
246
248
|
**_GLOBAL,
|
|
247
249
|
"id": _PRESETS,
|
blockether/vis/engine/_speech.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Speech API: voices, synthesis and transcription through the gateway engines.
|
|
2
2
|
|
|
3
|
-
Use `
|
|
3
|
+
Use `EngineClient.speech` from the SDK, or `vis.speech` inside an extension.
|
|
4
4
|
Both send the same canonical gateway requests.
|
|
5
5
|
"""
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@ from typing import TYPE_CHECKING, Any
|
|
|
14
14
|
from ._client import GatewayError, ProtocolError, VisTimeout
|
|
15
15
|
|
|
16
16
|
if TYPE_CHECKING:
|
|
17
|
-
from ._client import
|
|
17
|
+
from ._client import EngineClient
|
|
18
18
|
|
|
19
19
|
CLONING_ENGINE = "pocket-tts-local"
|
|
20
20
|
"""The engine that learns a voice from a recording."""
|
|
@@ -109,13 +109,13 @@ class Speech:
|
|
|
109
109
|
job; these methods wait for it and return the result.
|
|
110
110
|
"""
|
|
111
111
|
|
|
112
|
-
def __init__(self,
|
|
113
|
-
self.
|
|
112
|
+
def __init__(self, client: EngineClient):
|
|
113
|
+
self._client = client
|
|
114
114
|
|
|
115
115
|
def voices(self, engine: str | None = None) -> list[Voice]:
|
|
116
116
|
"""List the voices of `engine`, imported voices included."""
|
|
117
117
|
reply = _object(
|
|
118
|
-
self.
|
|
118
|
+
self._client.routes.get_speech_voices(query=_engine_query(engine)), "voices"
|
|
119
119
|
)
|
|
120
120
|
name = str((reply.get("engine") or {}).get("id") or engine or "")
|
|
121
121
|
return [_voice(entry, name) for entry in reply.get("voices") or []]
|
|
@@ -140,7 +140,7 @@ class Speech:
|
|
|
140
140
|
if not name or not name.strip():
|
|
141
141
|
raise ValueError("name must not be blank")
|
|
142
142
|
reply = _object(
|
|
143
|
-
self.
|
|
143
|
+
self._client.routes.post_speech_voices(
|
|
144
144
|
content=_audio_bytes(recording),
|
|
145
145
|
query=_engine_query(engine, name=name, lang=language, text=transcript),
|
|
146
146
|
),
|
|
@@ -174,7 +174,7 @@ class Speech:
|
|
|
174
174
|
if not body:
|
|
175
175
|
raise ValueError("give name, language or transcript")
|
|
176
176
|
reply = _object(
|
|
177
|
-
self.
|
|
177
|
+
self._client.routes.patch_speech_voice(
|
|
178
178
|
voice_id, body=body, query=_engine_query(engine)
|
|
179
179
|
),
|
|
180
180
|
"voice",
|
|
@@ -184,7 +184,9 @@ class Speech:
|
|
|
184
184
|
def remove_voice(self, voice_id: str, *, engine: str = CLONING_ENGINE) -> bool:
|
|
185
185
|
"""Delete an imported voice. Return False when the engine has no such voice."""
|
|
186
186
|
try:
|
|
187
|
-
self.
|
|
187
|
+
self._client.routes.delete_speech_voice(
|
|
188
|
+
voice_id, query=_engine_query(engine)
|
|
189
|
+
)
|
|
188
190
|
except GatewayError as error:
|
|
189
191
|
if error.status == 404:
|
|
190
192
|
return False
|
|
@@ -193,7 +195,7 @@ class Speech:
|
|
|
193
195
|
|
|
194
196
|
def voice_sample(self, voice_id: str, *, engine: str | None = None) -> bytes:
|
|
195
197
|
"""Return a short audio sample of a voice. Raises `GatewayError` 404 without one."""
|
|
196
|
-
return self.
|
|
198
|
+
return self._client.routes.get_speech_voice_sample(
|
|
197
199
|
voice_id, query=_engine_query(engine)
|
|
198
200
|
).content
|
|
199
201
|
|
|
@@ -201,8 +203,8 @@ class Speech:
|
|
|
201
203
|
"""Return the readiness of a speaking engine; `prepare=True` starts its download."""
|
|
202
204
|
query = _engine_query(engine)
|
|
203
205
|
if prepare:
|
|
204
|
-
return _object(self.
|
|
205
|
-
return _object(self.
|
|
206
|
+
return _object(self._client.routes.post_speech_model(query=query), "model")
|
|
207
|
+
return _object(self._client.routes.get_speech_model(query=query), "model")
|
|
206
208
|
|
|
207
209
|
def speak(
|
|
208
210
|
self,
|
|
@@ -229,7 +231,7 @@ class Speech:
|
|
|
229
231
|
body["voice"] = voice
|
|
230
232
|
if seed is not None:
|
|
231
233
|
body["seed"] = seed
|
|
232
|
-
response = self.
|
|
234
|
+
response = self._client._request(
|
|
233
235
|
"POST", "/v1/speech", body=body, query=_engine_query(engine)
|
|
234
236
|
)
|
|
235
237
|
if response.status == 200:
|
|
@@ -237,7 +239,7 @@ class Speech:
|
|
|
237
239
|
response.content, _media_type(response.headers), engine, voice, seed
|
|
238
240
|
)
|
|
239
241
|
job = self._wait("speech", response.json(), timeout)
|
|
240
|
-
audio = self.
|
|
242
|
+
audio = self._client.routes.get_speech_job_audio(job["id"])
|
|
241
243
|
return SpeechAudio(
|
|
242
244
|
audio.content,
|
|
243
245
|
_media_type(audio.headers),
|
|
@@ -258,7 +260,7 @@ class Speech:
|
|
|
258
260
|
Engines include `parakeet-local` and `vibevoice-asr-local`. Raises `GatewayError`
|
|
259
261
|
400 for audio that is not WAV and `VisTimeout` after `timeout` seconds.
|
|
260
262
|
"""
|
|
261
|
-
job = self.
|
|
263
|
+
job = self._client.routes.post_voice(
|
|
262
264
|
content=_audio_bytes(audio), query=_engine_query(engine)
|
|
263
265
|
)
|
|
264
266
|
job = self._wait("voice", job, timeout)
|
|
@@ -274,9 +276,9 @@ class Speech:
|
|
|
274
276
|
raise ProtocolError(f"invalid {direction} job")
|
|
275
277
|
if not job.get("is_done"):
|
|
276
278
|
follow = (
|
|
277
|
-
self.
|
|
279
|
+
self._client.speech_events
|
|
278
280
|
if direction == "speech"
|
|
279
|
-
else self.
|
|
281
|
+
else self._client.voice_events
|
|
280
282
|
)
|
|
281
283
|
# The job stream sends the current state first, then each change.
|
|
282
284
|
events = follow(job["id"])
|