covtl-console 3.1.9__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.
- covtl_console/__init__.py +18 -0
- covtl_console/__main__.py +6 -0
- covtl_console/_launchguard.py +129 -0
- covtl_console/_synthproc.py +78 -0
- covtl_console/server.py +2024 -0
- covtl_console/ui/css/app.css +600 -0
- covtl_console/ui/index.html +429 -0
- covtl_console/ui/js/api.js +385 -0
- covtl_console/ui/js/app.js +1354 -0
- covtl_console/ui/js/compiler.js +479 -0
- covtl_console/ui/js/data.js +214 -0
- covtl_console/ui/js/polar.js +625 -0
- covtl_console/ui/js/render.js +216 -0
- covtl_console/ui/js/spectrogram.js +294 -0
- covtl_console-3.1.9.dist-info/METADATA +459 -0
- covtl_console-3.1.9.dist-info/RECORD +21 -0
- covtl_console-3.1.9.dist-info/WHEEL +5 -0
- covtl_console-3.1.9.dist-info/entry_points.txt +2 -0
- covtl_console-3.1.9.dist-info/licenses/LICENSE +674 -0
- covtl_console-3.1.9.dist-info/licenses/THIRD_PARTY_NOTICES.md +25 -0
- covtl_console-3.1.9.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Frédéric Berthommier
|
|
2
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
3
|
+
"""covtl_console — the COVTL Lab Console (bridge + UI) as a package.
|
|
4
|
+
|
|
5
|
+
`python -m covtl_console` or the `covtl-console` script starts the
|
|
6
|
+
local bridge on http://127.0.0.1:8421. The UI assets live in
|
|
7
|
+
``covtl_console/ui/`` and are served by the bridge itself.
|
|
8
|
+
"""
|
|
9
|
+
__version__ = "3.1.9"
|
|
10
|
+
|
|
11
|
+
# Audit B1 (2026-11-06): the frozen Windows bundle fast-fails with
|
|
12
|
+
# 0xC0000409 (no traceback) when its executable sits in a non-ASCII
|
|
13
|
+
# path. Refuse politely BEFORE the server import loads the frozen
|
|
14
|
+
# extension modules; inert in every non-frozen interpreter.
|
|
15
|
+
from covtl_console._launchguard import refuse_nonascii_bundle
|
|
16
|
+
refuse_nonascii_bundle()
|
|
17
|
+
|
|
18
|
+
from covtl_console.server import main # noqa: F401,E402
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Frédéric Berthommier
|
|
2
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
3
|
+
"""Startup guard for packaged (frozen) builds — pre-release audit B1.
|
|
4
|
+
|
|
5
|
+
The 2026-11-06 pre-release audit established that the PyInstaller
|
|
6
|
+
6.22.3 onedir bundle fast-fails with 0xC0000409 (STATUS_STACK_BUFFER_
|
|
7
|
+
OVERRUN — no traceback, no message, Windows Event ID 1000) as soon as
|
|
8
|
+
the executable's path contains a non-ASCII character. Pure-Python
|
|
9
|
+
imports keep working in that state; the process dies while loading
|
|
10
|
+
the first frozen *extension* module during
|
|
11
|
+
``from covtl_console.server import main`` (the historical bug family
|
|
12
|
+
is real upstream: PyInstaller issue #5184, fixed once by PR #5189 in
|
|
13
|
+
2020, resurfaces here).
|
|
14
|
+
|
|
15
|
+
Until the regression is fixed upstream, this module converts the
|
|
16
|
+
silent crash into an explicit refusal. It runs BEFORE the server
|
|
17
|
+
import (see ``covtl_console/__init__.py``), so it strictly precedes
|
|
18
|
+
the extension-module loading that kills the process: it prints a
|
|
19
|
+
bilingual explanation on stderr — ASCII-safe, the offending path
|
|
20
|
+
transliterated so it renders in any console code page — appends one
|
|
21
|
+
line to ``covtl-console.log`` next to the executable (UTF-8, exact
|
|
22
|
+
path), then exits with code ``EXIT_CODE``. Non-frozen interpreters
|
|
23
|
+
(pip installs, dev checkouts, test suites) are never refused —
|
|
24
|
+
regular CPython handles Unicode paths; the audit proved the pip/venv
|
|
25
|
+
installs are unaffected. The audit also established that pure-Python
|
|
26
|
+
modules keep loading in the broken state (cmudict's diagnostic runs
|
|
27
|
+
before the crash), which is exactly what this guard relies on.
|
|
28
|
+
"""
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
import sys
|
|
32
|
+
|
|
33
|
+
EXIT_CODE = 80
|
|
34
|
+
LOG_NAME = "covtl-console.log"
|
|
35
|
+
|
|
36
|
+
_MESSAGE = """\
|
|
37
|
+
----------------------------------------------------------------------
|
|
38
|
+
COVTL Console cannot start here.
|
|
39
|
+
The path of covtl-console.exe contains non-ASCII characters (accents
|
|
40
|
+
or other symbols); the packaged Windows runtime cannot load its
|
|
41
|
+
extension modules from such a path yet (known PyInstaller bug family
|
|
42
|
+
- pre-release audit B1, 2026-11-06).
|
|
43
|
+
Path: {path}
|
|
44
|
+
Fix: move or rename the application folder so that every character in
|
|
45
|
+
the path is ASCII (unaccented letters, digits, '_', '-'), for example
|
|
46
|
+
C:\\Tools\\COVTL, then start covtl-console.exe again.
|
|
47
|
+
FR : le chemin du dossier contient des accents. Deplacez ou renommez
|
|
48
|
+
le dossier avec des caracteres non accentues (ex. C:\\Tools\\COVTL),
|
|
49
|
+
puis relancez covtl-console.exe.
|
|
50
|
+
----------------------------------------------------------------------
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def path_is_ascii(path: str) -> bool:
|
|
55
|
+
"""True when *path* encodes to ASCII (accents, greek, CJK fail)."""
|
|
56
|
+
try:
|
|
57
|
+
path.encode("ascii")
|
|
58
|
+
return True
|
|
59
|
+
except UnicodeEncodeError:
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def offending_path(sys_module=None):
|
|
64
|
+
"""The executable path that must be refused, or None to continue.
|
|
65
|
+
|
|
66
|
+
Refuses only frozen interpreters with a resolvable non-ASCII
|
|
67
|
+
``sys.executable``: a missing/empty path is never refused (when we
|
|
68
|
+
cannot tell, we do not block the user).
|
|
69
|
+
"""
|
|
70
|
+
sm = sys if sys_module is None else sys_module
|
|
71
|
+
if not getattr(sm, "frozen", False):
|
|
72
|
+
return None # regular interpreter: never refuse
|
|
73
|
+
exe = getattr(sm, "executable", "") or ""
|
|
74
|
+
if not exe:
|
|
75
|
+
return None
|
|
76
|
+
return None if path_is_ascii(exe) else exe
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _log_line(path: str) -> str:
|
|
80
|
+
try:
|
|
81
|
+
import time
|
|
82
|
+
stamp = time.strftime("%Y-%m-%d %H:%M:%S")
|
|
83
|
+
except Exception: # pragma: no cover
|
|
84
|
+
stamp = "?"
|
|
85
|
+
return f"[guard] {stamp} refused to start: non-ASCII executable path: {path}"
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def refuse_nonascii_bundle(sys_module=None, stream=None, log_dir=None):
|
|
89
|
+
"""Refuse (``SystemExit(EXIT_CODE)``) when a frozen build sits in a
|
|
90
|
+
non-ASCII path; return None when startup should continue.
|
|
91
|
+
|
|
92
|
+
Every step is best-effort: a guard that itself raised would be
|
|
93
|
+
worse than the disease it guards against, so I/O failures are
|
|
94
|
+
swallowed and the refusal (message + exit code) is preserved.
|
|
95
|
+
"""
|
|
96
|
+
bad = offending_path(sys_module)
|
|
97
|
+
if bad is None:
|
|
98
|
+
return None
|
|
99
|
+
sm = sys if sys_module is None else sys_module
|
|
100
|
+
try:
|
|
101
|
+
out = stream if stream is not None else getattr(sm, "stderr", None)
|
|
102
|
+
if out is not None:
|
|
103
|
+
text = _MESSAGE.format(path=bad)
|
|
104
|
+
try:
|
|
105
|
+
text.encode("ascii")
|
|
106
|
+
except UnicodeEncodeError:
|
|
107
|
+
# The offending path is non-ASCII; transliterate it so the
|
|
108
|
+
# message renders in ANY console code page (cp437 included)
|
|
109
|
+
# instead of raising UnicodeEncodeError on print.
|
|
110
|
+
text = text.encode("ascii", "backslashreplace").decode("ascii")
|
|
111
|
+
print(text, file=out)
|
|
112
|
+
out.flush()
|
|
113
|
+
except Exception: # pragma: no cover
|
|
114
|
+
pass
|
|
115
|
+
try: # best-effort trace in the launcher's log, next to the executable
|
|
116
|
+
import os.path
|
|
117
|
+
directory = log_dir if log_dir is not None \
|
|
118
|
+
else (os.path.dirname(bad) or ".")
|
|
119
|
+
with open(os.path.join(directory, LOG_NAME), "a",
|
|
120
|
+
encoding="utf-8") as fh:
|
|
121
|
+
fh.write(_log_line(bad) + "\n")
|
|
122
|
+
except Exception: # pragma: no cover
|
|
123
|
+
pass
|
|
124
|
+
try:
|
|
125
|
+
if getattr(sm, "stdout", None) is not None:
|
|
126
|
+
sm.stdout.flush()
|
|
127
|
+
except Exception: # pragma: no cover
|
|
128
|
+
pass
|
|
129
|
+
raise SystemExit(EXIT_CODE)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Frédéric Berthommier
|
|
2
|
+
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
3
|
+
"""Synthesis runner executed in a worker subprocess (N2 fix, 2026-11-07).
|
|
4
|
+
|
|
5
|
+
Why a subprocess
|
|
6
|
+
----------------
|
|
7
|
+
The VTL audio stage runs through ``vocaltractlab_cython.synth_block`` —
|
|
8
|
+
a native C/C++ extension that does NOT release the GIL. Running it in
|
|
9
|
+
a Python thread (the historical bridge worker) starves the uvicorn
|
|
10
|
+
event loop and the Starlette threadpool: /api/health stopped answering
|
|
11
|
+
for >= 30 s on a 570-character job and for ~13 minutes on a
|
|
12
|
+
4 900-character job (audit N2). In a separate PROCESS the GIL is
|
|
13
|
+
irrelevant: the console stays responsive while the engine works.
|
|
14
|
+
|
|
15
|
+
Design
|
|
16
|
+
------
|
|
17
|
+
* The runner lives in its own module — a fresh interpreter (spawn start
|
|
18
|
+
method, Windows) imports THIS file only, not the whole bridge (no
|
|
19
|
+
FastAPI app, no UI mount, no warm-up).
|
|
20
|
+
* The payload and the result are plain picklable dictionaries: paths
|
|
21
|
+
travel as strings, the engine result is flattened to the fields the
|
|
22
|
+
bridge actually consumes.
|
|
23
|
+
* The pool is created by the bridge with ``max_workers=1``: synthesis
|
|
24
|
+
jobs are serialized (the engine is CPU-bound on one core anyway) and
|
|
25
|
+
the global-state semantics of the speaker registry stay safe.
|
|
26
|
+
In-process fallback (same function!) covers environments where no
|
|
27
|
+
process pool can be created.
|
|
28
|
+
"""
|
|
29
|
+
from __future__ import annotations
|
|
30
|
+
|
|
31
|
+
from typing import Any, Dict
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def run_synthesis(payload: Dict[str, Any]) -> Dict[str, Any]:
|
|
35
|
+
"""Builds a Pipeline from primitive kwargs and runs the full chain.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
payload : dict
|
|
40
|
+
``pipeline``: Pipeline(**payload["pipeline"]) constructor kwargs;
|
|
41
|
+
``text``, ``output_dir`` (absolute path str), ``use_g2p``,
|
|
42
|
+
``video``, ``label`` (already sanitized by the bridge, N3),
|
|
43
|
+
``polar``, ``sampa_guard``: Pipeline.run parameters.
|
|
44
|
+
|
|
45
|
+
Returns
|
|
46
|
+
-------
|
|
47
|
+
dict
|
|
48
|
+
sampa, warnings, phrases (count), duration_s, n_frames,
|
|
49
|
+
tract_path / wav_path / polar_path / mp4_path (str or None),
|
|
50
|
+
stem (the engine's resolved file stem).
|
|
51
|
+
"""
|
|
52
|
+
from vtl_synth import Pipeline
|
|
53
|
+
|
|
54
|
+
pipe = Pipeline(**payload["pipeline"])
|
|
55
|
+
result = pipe.run(
|
|
56
|
+
payload["text"],
|
|
57
|
+
output_dir=payload["output_dir"],
|
|
58
|
+
use_g2p=payload["use_g2p"],
|
|
59
|
+
video=payload["video"],
|
|
60
|
+
label=payload["label"],
|
|
61
|
+
polar=payload["polar"],
|
|
62
|
+
sampa_guard=payload["sampa_guard"],
|
|
63
|
+
)
|
|
64
|
+
return {
|
|
65
|
+
"sampa": result.sampa,
|
|
66
|
+
"warnings": list(result.warnings),
|
|
67
|
+
"phrases": len(result.phrases),
|
|
68
|
+
"duration_s": result.duration_s,
|
|
69
|
+
"n_frames": int(result.n_frames),
|
|
70
|
+
"tract_path": str(result.tract_path),
|
|
71
|
+
"wav_path": str(result.wav_path),
|
|
72
|
+
"polar_path": (str(result.polar_path)
|
|
73
|
+
if result.polar_path is not None else None),
|
|
74
|
+
"mp4_path": (str(result.mp4_path)
|
|
75
|
+
if getattr(result, "mp4_path", None) is not None
|
|
76
|
+
else None),
|
|
77
|
+
"stem": result.tract_path.stem,
|
|
78
|
+
}
|