awdeck 0.1.1__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.
- awdeck-0.1.1/LICENSE +21 -0
- awdeck-0.1.1/PKG-INFO +98 -0
- awdeck-0.1.1/README.md +86 -0
- awdeck-0.1.1/awdeck/__init__.py +16 -0
- awdeck-0.1.1/awdeck/_doctor.py +198 -0
- awdeck-0.1.1/awdeck/cli.py +144 -0
- awdeck-0.1.1/awdeck/narrate.py +193 -0
- awdeck-0.1.1/awdeck/render.py +265 -0
- awdeck-0.1.1/awdeck.egg-info/PKG-INFO +98 -0
- awdeck-0.1.1/awdeck.egg-info/SOURCES.txt +15 -0
- awdeck-0.1.1/awdeck.egg-info/dependency_links.txt +1 -0
- awdeck-0.1.1/awdeck.egg-info/entry_points.txt +2 -0
- awdeck-0.1.1/awdeck.egg-info/requires.txt +1 -0
- awdeck-0.1.1/awdeck.egg-info/top_level.txt +1 -0
- awdeck-0.1.1/pyproject.toml +21 -0
- awdeck-0.1.1/setup.cfg +4 -0
- awdeck-0.1.1/tests/test_awdeck.py +220 -0
awdeck-0.1.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aitherium
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
awdeck-0.1.1/PKG-INFO
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awdeck
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Aither World Deck - turn a slides outline into a narrated video, and record which voice actually spoke it.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/Aitherium
|
|
7
|
+
Requires-Python: >=3.10
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pillow>=10.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# awdeck — Aither World Deck
|
|
14
|
+
|
|
15
|
+
Turn a JSON outline into a narrated MP4, and read back which voice actually spoke it.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
export AWVOICE_TTS_URL=http://127.0.0.1:8084/voice/synthesize
|
|
19
|
+
awdeck doctor # is the plane reachable?
|
|
20
|
+
awdeck render slides.json --out talk.mp4 --voice onyx
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Why the manifest exists
|
|
24
|
+
|
|
25
|
+
A rendered video looks identical whether a neural voice plane narrated it or a
|
|
26
|
+
2010-era desktop speech synthesiser did. The artifact cannot be audited by looking
|
|
27
|
+
at it, so `awdeck` writes a sidecar that can be:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"deck": "talk",
|
|
32
|
+
"slides": 15,
|
|
33
|
+
"duration_s": 507.92,
|
|
34
|
+
"narration": {
|
|
35
|
+
"path": "plane",
|
|
36
|
+
"voice": "onyx",
|
|
37
|
+
"voice_served": "en-GB-SoniaNeural",
|
|
38
|
+
"voices_served": ["en-GB-SoniaNeural"],
|
|
39
|
+
"provider": "awvoice:http://127.0.0.1:8084/voice/synthesize",
|
|
40
|
+
"plane_reachable": true,
|
|
41
|
+
"slides_narrated": 15,
|
|
42
|
+
"slides_degraded": 0
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Three fields carry the weight:
|
|
48
|
+
|
|
49
|
+
- **`path`** — `plane` or `local-fallback`, and it is **worst-case across the whole
|
|
50
|
+
deck**, not the last slide. One degraded slide out of fifteen makes the deck
|
|
51
|
+
`local-fallback`. A fallback taken while `plane_reachable` is true is a silent
|
|
52
|
+
downgrade, and `check_media_narration_plane.py` (MNP003) fails the build on it.
|
|
53
|
+
- **`slides_degraded`** — how many slides took the degraded path. `0` is the only
|
|
54
|
+
number that means what you hope it means.
|
|
55
|
+
- **`voice_served`** / **`voices_served`** — what the service actually produced, read
|
|
56
|
+
back from its own response rather than assumed from the request.
|
|
57
|
+
|
|
58
|
+
## Fail-closed by default
|
|
59
|
+
|
|
60
|
+
`awdeck` will **not** narrate off-plane unless you ask:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
$ awdeck render slides.json --out x.mp4
|
|
64
|
+
awdeck: voice plane unreachable (AWVOICE_TTS_URL=None) and fallback not allowed.
|
|
65
|
+
Fix the plane, or pass allow_fallback=True and accept a recorded downgrade.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
That default exists because of a measured incident (2026-09-19): one long-job
|
|
69
|
+
transport failure was read as "the fleet is down", a six-minute video was narrated
|
|
70
|
+
by Windows SAPI while the voice plane was healthy the whole time, and the only
|
|
71
|
+
thing that caught it was a human listening to it.
|
|
72
|
+
|
|
73
|
+
## Known defect in the voice plane
|
|
74
|
+
|
|
75
|
+
`/voice/synthesize` accepts a `voice` parameter and, as measured on 2026-09-19,
|
|
76
|
+
serves `en-GB-SoniaNeural` regardless — all six advertised names and three real
|
|
77
|
+
edge voice names returned the same speaker. `awdeck` cannot fix that, so it
|
|
78
|
+
records it: `voice_served` will differ from `voice`, and the CLI prints a NOTE.
|
|
79
|
+
|
|
80
|
+
## Slides format
|
|
81
|
+
|
|
82
|
+
A JSON array. Three layouts; `notes` is the narration script for that slide.
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
[
|
|
86
|
+
{"layout": "title", "title": "...", "subtitle": "...", "notes": "..."},
|
|
87
|
+
{"layout": "bullets", "title": "...", "bullets": ["..."], "notes": "..."},
|
|
88
|
+
{"layout": "quote", "title": "...", "quote": "...", "notes": "..."}
|
|
89
|
+
]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Requires
|
|
93
|
+
|
|
94
|
+
`ffmpeg` and `ffprobe` on PATH, Pillow, and a voice-shaped HTTP service at
|
|
95
|
+
`AWVOICE_TTS_URL` accepting `{text, voice, format, return_base64}`.
|
|
96
|
+
|
|
97
|
+
Pairs with [`awvoice`](../awvoice) (the speech brick this speaks through), `awsh`,
|
|
98
|
+
`awdk`, `mediaforge` and `awrtifact`.
|
awdeck-0.1.1/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# awdeck — Aither World Deck
|
|
2
|
+
|
|
3
|
+
Turn a JSON outline into a narrated MP4, and read back which voice actually spoke it.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
export AWVOICE_TTS_URL=http://127.0.0.1:8084/voice/synthesize
|
|
7
|
+
awdeck doctor # is the plane reachable?
|
|
8
|
+
awdeck render slides.json --out talk.mp4 --voice onyx
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Why the manifest exists
|
|
12
|
+
|
|
13
|
+
A rendered video looks identical whether a neural voice plane narrated it or a
|
|
14
|
+
2010-era desktop speech synthesiser did. The artifact cannot be audited by looking
|
|
15
|
+
at it, so `awdeck` writes a sidecar that can be:
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"deck": "talk",
|
|
20
|
+
"slides": 15,
|
|
21
|
+
"duration_s": 507.92,
|
|
22
|
+
"narration": {
|
|
23
|
+
"path": "plane",
|
|
24
|
+
"voice": "onyx",
|
|
25
|
+
"voice_served": "en-GB-SoniaNeural",
|
|
26
|
+
"voices_served": ["en-GB-SoniaNeural"],
|
|
27
|
+
"provider": "awvoice:http://127.0.0.1:8084/voice/synthesize",
|
|
28
|
+
"plane_reachable": true,
|
|
29
|
+
"slides_narrated": 15,
|
|
30
|
+
"slides_degraded": 0
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Three fields carry the weight:
|
|
36
|
+
|
|
37
|
+
- **`path`** — `plane` or `local-fallback`, and it is **worst-case across the whole
|
|
38
|
+
deck**, not the last slide. One degraded slide out of fifteen makes the deck
|
|
39
|
+
`local-fallback`. A fallback taken while `plane_reachable` is true is a silent
|
|
40
|
+
downgrade, and `check_media_narration_plane.py` (MNP003) fails the build on it.
|
|
41
|
+
- **`slides_degraded`** — how many slides took the degraded path. `0` is the only
|
|
42
|
+
number that means what you hope it means.
|
|
43
|
+
- **`voice_served`** / **`voices_served`** — what the service actually produced, read
|
|
44
|
+
back from its own response rather than assumed from the request.
|
|
45
|
+
|
|
46
|
+
## Fail-closed by default
|
|
47
|
+
|
|
48
|
+
`awdeck` will **not** narrate off-plane unless you ask:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
$ awdeck render slides.json --out x.mp4
|
|
52
|
+
awdeck: voice plane unreachable (AWVOICE_TTS_URL=None) and fallback not allowed.
|
|
53
|
+
Fix the plane, or pass allow_fallback=True and accept a recorded downgrade.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
That default exists because of a measured incident (2026-09-19): one long-job
|
|
57
|
+
transport failure was read as "the fleet is down", a six-minute video was narrated
|
|
58
|
+
by Windows SAPI while the voice plane was healthy the whole time, and the only
|
|
59
|
+
thing that caught it was a human listening to it.
|
|
60
|
+
|
|
61
|
+
## Known defect in the voice plane
|
|
62
|
+
|
|
63
|
+
`/voice/synthesize` accepts a `voice` parameter and, as measured on 2026-09-19,
|
|
64
|
+
serves `en-GB-SoniaNeural` regardless — all six advertised names and three real
|
|
65
|
+
edge voice names returned the same speaker. `awdeck` cannot fix that, so it
|
|
66
|
+
records it: `voice_served` will differ from `voice`, and the CLI prints a NOTE.
|
|
67
|
+
|
|
68
|
+
## Slides format
|
|
69
|
+
|
|
70
|
+
A JSON array. Three layouts; `notes` is the narration script for that slide.
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
[
|
|
74
|
+
{"layout": "title", "title": "...", "subtitle": "...", "notes": "..."},
|
|
75
|
+
{"layout": "bullets", "title": "...", "bullets": ["..."], "notes": "..."},
|
|
76
|
+
{"layout": "quote", "title": "...", "quote": "...", "notes": "..."}
|
|
77
|
+
]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Requires
|
|
81
|
+
|
|
82
|
+
`ffmpeg` and `ffprobe` on PATH, Pillow, and a voice-shaped HTTP service at
|
|
83
|
+
`AWVOICE_TTS_URL` accepting `{text, voice, format, return_base64}`.
|
|
84
|
+
|
|
85
|
+
Pairs with [`awvoice`](../awvoice) (the speech brick this speaks through), `awsh`,
|
|
86
|
+
`awdk`, `mediaforge` and `awrtifact`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""awdeck - Aither World Deck. A slides outline becomes a narrated video."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.1"
|
|
4
|
+
|
|
5
|
+
from .narrate import FALLBACK, PLANE, NarrationPath, probe_plane, synthesize
|
|
6
|
+
from .render import render, render_frame
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"FALLBACK",
|
|
10
|
+
"PLANE",
|
|
11
|
+
"NarrationPath",
|
|
12
|
+
"probe_plane",
|
|
13
|
+
"render",
|
|
14
|
+
"render_frame",
|
|
15
|
+
"synthesize",
|
|
16
|
+
]
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""Stack-aware `doctor` for awdeck.
|
|
2
|
+
|
|
3
|
+
GENERATED BY gen_aw_doctor.py -- DO NOT EDIT.
|
|
4
|
+
Regenerate it with the generator named above; a hand-edit here is reverted by
|
|
5
|
+
the next run and fails the parity gate.
|
|
6
|
+
|
|
7
|
+
Why a doctor exists at all: the aw* bricks are designed to COMPOSE, so the
|
|
8
|
+
interesting failures live BETWEEN them. "awdeck is installed" is not the useful
|
|
9
|
+
fact -- "awdeck is installed and the thing it pairs with is not" is. This reports
|
|
10
|
+
the whole stack, not just itself.
|
|
11
|
+
|
|
12
|
+
stdlib only, on purpose: a diagnostic that cannot run because a dependency is
|
|
13
|
+
missing is worthless precisely when you need it.
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import importlib.util
|
|
18
|
+
import os
|
|
19
|
+
import shutil
|
|
20
|
+
import sys
|
|
21
|
+
|
|
22
|
+
#: Frozen from the Aither World registry at generation time. A shipped
|
|
23
|
+
#: package cannot read the registry, and a doctor that guessed at the family
|
|
24
|
+
#: would go stale in silence. Regenerate to update.
|
|
25
|
+
SELF = 'awdeck'
|
|
26
|
+
FAMILY = [
|
|
27
|
+
'awask', 'awavatar', 'awbac', 'awbrain', 'awbrowse', 'awcams', 'awclassify', 'awdecide',
|
|
28
|
+
'awdelphi', 'awdit', 'awembed', 'awevolve', 'awfind', 'awflow', 'awfocus', 'awgit', 'awgraph',
|
|
29
|
+
'awgym', 'awiam', 'awkno', 'awm', 'awmail', 'awmine', 'awnboard', 'awnest', 'awnet', 'awplay',
|
|
30
|
+
'awpool', 'awpredict', 'awprism', 'awprove', 'awreason', 'awrecover', 'awrecurse', 'awrelay',
|
|
31
|
+
'awrena', 'awrepl', 'awreport', 'awresearch', 'awrise', 'awrouter', 'awrtifact', 'awrun',
|
|
32
|
+
'awscope', 'awscreen', 'awseal', 'awsettings', 'awshare', 'awsprite', 'awstorage', 'awsuite',
|
|
33
|
+
'awswarm', 'awtax', 'awtoll', 'awtunnel', 'awvision', 'awvoice', 'awwall', 'gawbbonet',
|
|
34
|
+
]
|
|
35
|
+
PAIRS_WITH = ['adk', 'awrtifact', 'awvoice']
|
|
36
|
+
|
|
37
|
+
#: This brick's OWN config, read out of its source at generation time.
|
|
38
|
+
#: ENV_REQUIRED is `os.environ["X"]` -- absent, that is a KeyError the moment
|
|
39
|
+
#: the line runs. ENV_OPTIONAL is `os.getenv("X")`, which returns None and lets
|
|
40
|
+
#: the caller cope. Only this brick's namespace is listed: reporting the
|
|
41
|
+
#: platform-wide vars it also touches would be noise, and a doctor that floods
|
|
42
|
+
#: gets ignored.
|
|
43
|
+
ENV_REQUIRED = ['AWDECK_FONT_DIR']
|
|
44
|
+
ENV_OPTIONAL = []
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _installed(mod: str) -> "str | None":
|
|
48
|
+
"""Version if importable, else None. Never raises -- a broken sibling must
|
|
49
|
+
not take the diagnostic down with it."""
|
|
50
|
+
try:
|
|
51
|
+
if importlib.util.find_spec(mod) is None:
|
|
52
|
+
return None
|
|
53
|
+
except (ImportError, ValueError):
|
|
54
|
+
return None
|
|
55
|
+
try:
|
|
56
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
57
|
+
try:
|
|
58
|
+
return version(mod)
|
|
59
|
+
except PackageNotFoundError:
|
|
60
|
+
return "installed"
|
|
61
|
+
except Exception:
|
|
62
|
+
return "installed"
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def report(out=None) -> int:
|
|
66
|
+
"""Print the stack picture. 0 = this brick and its pairs are present."""
|
|
67
|
+
out = out or sys.stdout
|
|
68
|
+
print(f"{SELF} doctor", file=out)
|
|
69
|
+
|
|
70
|
+
mine = _installed(SELF)
|
|
71
|
+
print(f" self {SELF} {mine or 'NOT IMPORTABLE'}", file=out)
|
|
72
|
+
shim = shutil.which(SELF)
|
|
73
|
+
print(f" command {shim or 'not on PATH'}", file=out)
|
|
74
|
+
|
|
75
|
+
# The stack. Siblings this brick pairs with are called out separately,
|
|
76
|
+
# because a missing pair is a REASON, while a missing unrelated brick is
|
|
77
|
+
# just a fact about your machine.
|
|
78
|
+
missing_pairs, present = [], []
|
|
79
|
+
for name in FAMILY:
|
|
80
|
+
v = _installed(name)
|
|
81
|
+
if v:
|
|
82
|
+
present.append(name)
|
|
83
|
+
elif name in PAIRS_WITH:
|
|
84
|
+
missing_pairs.append(name)
|
|
85
|
+
print(f" stack {len(present)}/{len(FAMILY)} aw* packages installed",
|
|
86
|
+
file=out)
|
|
87
|
+
if present:
|
|
88
|
+
print(f" {' '.join(sorted(present))}", file=out)
|
|
89
|
+
|
|
90
|
+
missing_req = [v for v in ENV_REQUIRED if not os.environ.get(v)]
|
|
91
|
+
if ENV_REQUIRED or ENV_OPTIONAL:
|
|
92
|
+
have = sum(1 for v in ENV_REQUIRED + ENV_OPTIONAL if os.environ.get(v))
|
|
93
|
+
total = len(ENV_REQUIRED) + len(ENV_OPTIONAL)
|
|
94
|
+
print(f" config {have}/{total} of this brick's own vars set", file=out)
|
|
95
|
+
if missing_req:
|
|
96
|
+
# Not a preference. os.environ[...] raises the moment it runs.
|
|
97
|
+
print(f" MISSING REQUIRED: {' '.join(missing_req)}", file=out)
|
|
98
|
+
|
|
99
|
+
local = _local_checks()
|
|
100
|
+
for line in local:
|
|
101
|
+
print(f" {line}", file=out)
|
|
102
|
+
problems, unjudged = _local_verdict()
|
|
103
|
+
|
|
104
|
+
if mine is None:
|
|
105
|
+
print(f"\nverdict: {SELF} itself is not importable. Reinstall it before "
|
|
106
|
+
f"anything else here means much.", file=out)
|
|
107
|
+
return 1
|
|
108
|
+
if missing_req:
|
|
109
|
+
print(f"\nverdict: {SELF} is missing required config "
|
|
110
|
+
f"({', '.join(missing_req)}). Those are read with os.environ[...], "
|
|
111
|
+
f"so the code path that needs them raises rather than degrades.",
|
|
112
|
+
file=out)
|
|
113
|
+
return 1
|
|
114
|
+
# A measured NO outranks a missing optional pair: awrise printed
|
|
115
|
+
# "nothing wakes run-due" and still exited 0 because the missing-pairs
|
|
116
|
+
# branch returned first (measured 2026-09-20).
|
|
117
|
+
if problems:
|
|
118
|
+
for p in problems:
|
|
119
|
+
print(f"\nverdict: {p}", file=out)
|
|
120
|
+
return 1
|
|
121
|
+
if unjudged:
|
|
122
|
+
for u in unjudged:
|
|
123
|
+
print(f"\nverdict: UNJUDGED -- could not judge: {u}", file=out)
|
|
124
|
+
return 2
|
|
125
|
+
if missing_pairs:
|
|
126
|
+
print(f"\nverdict: {SELF} works, but pairs with "
|
|
127
|
+
f"{', '.join(sorted(missing_pairs))} which "
|
|
128
|
+
f"{'is' if len(missing_pairs) == 1 else 'are'} not installed. "
|
|
129
|
+
f"That is a capability you are missing, not an error.", file=out)
|
|
130
|
+
return 0
|
|
131
|
+
print(f"\nverdict: {SELF} and everything it pairs with are present.", file=out)
|
|
132
|
+
return 0
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _local_verdict() -> tuple:
|
|
136
|
+
"""The brick's OWN verdict, folded into the exit code.
|
|
137
|
+
|
|
138
|
+
Without this the local lines are DECORATION. Measured 2026-09-20: awrise
|
|
139
|
+
printed "hostclock NOT INSTALLED -- nothing wakes run-due" and "last tick
|
|
140
|
+
never", then exited 0 -- teaching an operator that a doctor exit code
|
|
141
|
+
carries no information. A brick opts in with `_doctor_local_verdict()`
|
|
142
|
+
returning (problems, unjudged); a brick without one is unaffected.
|
|
143
|
+
"""
|
|
144
|
+
try:
|
|
145
|
+
mod = importlib.import_module(f"{SELF}.doctor_local")
|
|
146
|
+
problems, unjudged = mod._doctor_local_verdict()
|
|
147
|
+
except Exception: # noqa: BLE001
|
|
148
|
+
return [], []
|
|
149
|
+
return list(problems or []), list(unjudged or [])
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def _local_checks() -> "list[str]":
|
|
153
|
+
"""Per-brick checks, if this package defines them.
|
|
154
|
+
|
|
155
|
+
Kept as a HOOK rather than generated guesses: the generator knows the family
|
|
156
|
+
from the registry, but it does not know what awdeck needs at runtime, and a
|
|
157
|
+
doctor that invented config requirements would be confidently wrong. A
|
|
158
|
+
package supplies `_doctor_local()` returning display lines; absent, the
|
|
159
|
+
stack picture above still stands on its own.
|
|
160
|
+
"""
|
|
161
|
+
try:
|
|
162
|
+
mod = importlib.import_module(f"{SELF}.doctor_local")
|
|
163
|
+
except Exception:
|
|
164
|
+
return []
|
|
165
|
+
try:
|
|
166
|
+
return list(mod._doctor_local())
|
|
167
|
+
except Exception as exc: # noqa: BLE001
|
|
168
|
+
return [f"local checks raised {type(exc).__name__}: {exc}"]
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def main(argv: "list[str] | None" = None) -> int:
|
|
172
|
+
# --self-test delegates to a SIBLING module when one exists.
|
|
173
|
+
#
|
|
174
|
+
# This file is generated and a fresh run replaces it, so a self-test
|
|
175
|
+
# written HERE is deleted by the next regeneration. awdelphi learned that
|
|
176
|
+
# the expensive way: 125 lines exercising four real failure paths --
|
|
177
|
+
# convergence, roster anonymization, resume, gateway-down -- lived in this
|
|
178
|
+
# file and were destroyed by a routine regeneration, silently, leaving a
|
|
179
|
+
# --self-test flag that reported PASS while asserting nothing.
|
|
180
|
+
#
|
|
181
|
+
# So the seam is a separate module the generator never writes. A package
|
|
182
|
+
# with real machinery to prove puts it in _selftest.py; everything else
|
|
183
|
+
# keeps the honest answer below rather than a self-test that only ever
|
|
184
|
+
# passes.
|
|
185
|
+
argv = list(argv if argv is not None else __import__("sys").argv[1:])
|
|
186
|
+
if "--self-test" in argv:
|
|
187
|
+
try:
|
|
188
|
+
from . import _selftest as _st
|
|
189
|
+
except Exception:
|
|
190
|
+
print("no _selftest module: this doctor reports the stack, and has",
|
|
191
|
+
"no machinery of its own to prove")
|
|
192
|
+
return 0
|
|
193
|
+
return int(_st.run())
|
|
194
|
+
return report()
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
if __name__ == "__main__":
|
|
198
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"""awdeck — Aither World Deck. Turn a slides outline into a narrated video."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from .narrate import probe_plane, tts_url
|
|
11
|
+
from .render import render
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def _self_test() -> int:
|
|
15
|
+
"""Exit 0 only when each guard is PROVEN to still fire. Never 0 on silence."""
|
|
16
|
+
import tempfile
|
|
17
|
+
|
|
18
|
+
from . import narrate as _n
|
|
19
|
+
|
|
20
|
+
failures: list[str] = []
|
|
21
|
+
real_probe, real_url, real_plane = _n.probe_plane, _n.tts_url, _n._synthesize_plane
|
|
22
|
+
try:
|
|
23
|
+
with tempfile.TemporaryDirectory() as td:
|
|
24
|
+
out = Path(td) / "a.mp3"
|
|
25
|
+
|
|
26
|
+
# arm 1 — plane reachable, synthesis fails: must RAISE, not degrade.
|
|
27
|
+
_n.tts_url = lambda env=None: "http://voice/synthesize"
|
|
28
|
+
_n.probe_plane = lambda url, timeout=4.0: True
|
|
29
|
+
|
|
30
|
+
def _boom(text, o, v):
|
|
31
|
+
raise RuntimeError("stream closed")
|
|
32
|
+
|
|
33
|
+
_n._synthesize_plane = _boom
|
|
34
|
+
try:
|
|
35
|
+
_n.synthesize("x", out, allow_fallback=False)
|
|
36
|
+
except RuntimeError as exc:
|
|
37
|
+
if "Refusing to silently downgrade" not in str(exc):
|
|
38
|
+
failures.append(f"arm 1: wrong error: {exc}")
|
|
39
|
+
else:
|
|
40
|
+
failures.append("arm 1: a silent downgrade was ALLOWED")
|
|
41
|
+
|
|
42
|
+
# arm 2 — plane unreachable, fallback not allowed: must RAISE.
|
|
43
|
+
_n.tts_url = lambda env=None: None
|
|
44
|
+
_n.probe_plane = lambda url, timeout=4.0: False
|
|
45
|
+
refused = False
|
|
46
|
+
try:
|
|
47
|
+
_n.synthesize("x", out, allow_fallback=False)
|
|
48
|
+
except RuntimeError:
|
|
49
|
+
refused = True # correct: no plane and no permission
|
|
50
|
+
if not refused:
|
|
51
|
+
failures.append("arm 2: rendered with no plane and no permission")
|
|
52
|
+
|
|
53
|
+
# arm 3 — a downgrade taken on purpose is recorded, not hidden.
|
|
54
|
+
n = _n.NarrationPath(_n.FALLBACK, "sapi", "windows-sapi", plane_reachable=True)
|
|
55
|
+
if not n.is_silent_downgrade:
|
|
56
|
+
failures.append("arm 3: is_silent_downgrade did not flag the defect")
|
|
57
|
+
|
|
58
|
+
# arm 4 — a substituted voice is visible.
|
|
59
|
+
sub = _n.NarrationPath(_n.PLANE, "onyx", "p", True, voice_served="en-GB-SoniaNeural")
|
|
60
|
+
if not sub.voice_substituted:
|
|
61
|
+
failures.append("arm 4: voice substitution was not detected")
|
|
62
|
+
finally:
|
|
63
|
+
_n.probe_plane, _n.tts_url, _n._synthesize_plane = real_probe, real_url, real_plane
|
|
64
|
+
|
|
65
|
+
if failures:
|
|
66
|
+
for f in failures:
|
|
67
|
+
print(f"SELF-TEST FAIL: {f}", file=sys.stderr)
|
|
68
|
+
return 1
|
|
69
|
+
print("awdeck self-test OK: 4 arms, the fail-closed guards still fire")
|
|
70
|
+
return 0
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def main(argv: list[str] | None = None) -> int:
|
|
74
|
+
# GENERATED repo-state intercept (gen_aw_doctor.py) -- do not edit
|
|
75
|
+
try:
|
|
76
|
+
from awgit import state as _aw_state
|
|
77
|
+
except Exception:
|
|
78
|
+
_aw_state = None
|
|
79
|
+
if _aw_state is not None:
|
|
80
|
+
_sv = locals().get("argv")
|
|
81
|
+
if _aw_state.cli_banner(_sv if _sv is not None else __import__("sys").argv[1:]):
|
|
82
|
+
return 0
|
|
83
|
+
ap = argparse.ArgumentParser(prog="awdeck", description=__doc__)
|
|
84
|
+
# The family contract is `awXXX --self-test` (34 of the bricks do this), so
|
|
85
|
+
# the FLAG has to work, not only the subcommand. `required=True` on the
|
|
86
|
+
# subparsers made the bare flag exit 2 with "the following arguments are
|
|
87
|
+
# required: cmd" — which reads as a broken CLI, not as a passing self-test.
|
|
88
|
+
ap.add_argument("--self-test", action="store_true", help=argparse.SUPPRESS)
|
|
89
|
+
sub = ap.add_subparsers(dest="cmd")
|
|
90
|
+
|
|
91
|
+
r = sub.add_parser("render", help="slides.json -> narrated mp4 + manifest")
|
|
92
|
+
r.add_argument("slides", type=Path)
|
|
93
|
+
r.add_argument("--out", type=Path, required=True)
|
|
94
|
+
r.add_argument("--voice", default="onyx")
|
|
95
|
+
r.add_argument(
|
|
96
|
+
"--allow-fallback",
|
|
97
|
+
action="store_true",
|
|
98
|
+
help="permit a degraded local voice; the manifest records that it happened",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
sub.add_parser("doctor", help="is the voice plane reachable?")
|
|
102
|
+
sub.add_parser("self-test", help="prove the fail-closed guard still fires")
|
|
103
|
+
args = ap.parse_args(argv)
|
|
104
|
+
|
|
105
|
+
if getattr(args, "self_test", False) or args.cmd == "self-test":
|
|
106
|
+
return _self_test()
|
|
107
|
+
|
|
108
|
+
if args.cmd is None:
|
|
109
|
+
ap.print_help(sys.stderr)
|
|
110
|
+
return 2
|
|
111
|
+
|
|
112
|
+
if args.cmd == "doctor":
|
|
113
|
+
url = tts_url()
|
|
114
|
+
ok = probe_plane(url)
|
|
115
|
+
print(f"AWVOICE_TTS_URL = {url or '(unset)'}")
|
|
116
|
+
print(f"plane reachable = {ok}")
|
|
117
|
+
return 0 if ok else 1
|
|
118
|
+
|
|
119
|
+
try:
|
|
120
|
+
manifest = render(
|
|
121
|
+
args.slides,
|
|
122
|
+
args.out,
|
|
123
|
+
voice=args.voice,
|
|
124
|
+
allow_fallback=args.allow_fallback,
|
|
125
|
+
)
|
|
126
|
+
except RuntimeError as exc:
|
|
127
|
+
print(f"awdeck: {exc}", file=sys.stderr)
|
|
128
|
+
return 1
|
|
129
|
+
|
|
130
|
+
print(json.dumps(manifest, indent=2))
|
|
131
|
+
n = manifest["narration"]
|
|
132
|
+
if n.get("path") == "local-fallback" and n.get("plane_reachable"):
|
|
133
|
+
print("\nWARNING: degraded voice while the plane was up (MNP003)", file=sys.stderr)
|
|
134
|
+
return 1
|
|
135
|
+
if n.get("voice_served") and n["voice_served"] != n.get("voice"):
|
|
136
|
+
print(
|
|
137
|
+
f"\nNOTE: asked for {n['voice']!r}, served {n['voice_served']!r}",
|
|
138
|
+
file=sys.stderr,
|
|
139
|
+
)
|
|
140
|
+
return 0
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
if __name__ == "__main__":
|
|
144
|
+
sys.exit(main())
|