litesuite-rust-sidecar 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.
Files changed (73) hide show
  1. litesuite_rust_sidecar-0.1.0/LICENSE +21 -0
  2. litesuite_rust_sidecar-0.1.0/PKG-INFO +60 -0
  3. litesuite_rust_sidecar-0.1.0/README.md +38 -0
  4. litesuite_rust_sidecar-0.1.0/pyproject.toml +41 -0
  5. litesuite_rust_sidecar-0.1.0/setup.cfg +4 -0
  6. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/__init__.py +3 -0
  7. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/auth.py +51 -0
  8. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/envsetup.py +135 -0
  9. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/__init__.py +0 -0
  10. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/__main__.py +10 -0
  11. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/ace_step_gguf_manifest.py +118 -0
  12. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/__init__.py +0 -0
  13. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/ace_step.py +241 -0
  14. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/ace_step_gguf.py +329 -0
  15. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/audioldm2.py +81 -0
  16. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/bark.py +69 -0
  17. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/chatterbox.py +112 -0
  18. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/minimax_music3_gguf.py +151 -0
  19. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/musicgen.py +95 -0
  20. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/stable_audio.py +89 -0
  21. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/stable_audio_small.py +175 -0
  22. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/vibevoice.py +264 -0
  23. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/backends/yue.py +145 -0
  24. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/envs.toml +78 -0
  25. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/hub_downloader.py +495 -0
  26. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/minimax_music3_gguf_manifest.py +142 -0
  27. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/model_paths.py +17 -0
  28. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/port_reaper.py +92 -0
  29. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/server.py +428 -0
  30. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/sidecar_log.py +28 -0
  31. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/LICENSE +21 -0
  32. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/PROVENANCE.md +212 -0
  33. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/__init__.py +16 -0
  34. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/configs/qwen2.5_1.5b_64k.json +112 -0
  35. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/configs/qwen2.5_7b_32k.json +113 -0
  36. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/__init__.py +14 -0
  37. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/configuration_vibevoice.py +406 -0
  38. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/configuration_vibevoice_streaming.py +104 -0
  39. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modeling_vibevoice.py +496 -0
  40. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modeling_vibevoice_asr.py +522 -0
  41. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modeling_vibevoice_streaming.py +190 -0
  42. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modeling_vibevoice_streaming_inference.py +906 -0
  43. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modular_vibevoice_diffusion_head.py +287 -0
  44. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modular_vibevoice_text_tokenizer.py +313 -0
  45. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/modular_vibevoice_tokenizer.py +1207 -0
  46. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/modular/streamer.py +264 -0
  47. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/processor/__init__.py +11 -0
  48. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/processor/audio_utils.py +217 -0
  49. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/processor/vibevoice_asr_processor.py +572 -0
  50. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/processor/vibevoice_processor.py +692 -0
  51. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/processor/vibevoice_streaming_processor.py +409 -0
  52. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/processor/vibevoice_tokenizer_processor.py +413 -0
  53. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/schedule/__init__.py +0 -0
  54. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/schedule/dpm_solver.py +1065 -0
  55. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/schedule/timestep_sampler.py +19 -0
  56. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar/litesound/vendor/vibevoice/scripts/__init__.py +0 -0
  57. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar.egg-info/PKG-INFO +60 -0
  58. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar.egg-info/SOURCES.txt +71 -0
  59. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar.egg-info/dependency_links.txt +1 -0
  60. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar.egg-info/requires.txt +13 -0
  61. litesuite_rust_sidecar-0.1.0/src/litesuite_rust_sidecar.egg-info/top_level.txt +1 -0
  62. litesuite_rust_sidecar-0.1.0/tests/test_ace_step_launch.py +52 -0
  63. litesuite_rust_sidecar-0.1.0/tests/test_backend_registry.py +153 -0
  64. litesuite_rust_sidecar-0.1.0/tests/test_envsetup.py +96 -0
  65. litesuite_rust_sidecar-0.1.0/tests/test_generate_kwargs.py +270 -0
  66. litesuite_rust_sidecar-0.1.0/tests/test_launch_token.py +66 -0
  67. litesuite_rust_sidecar-0.1.0/tests/test_model_paths.py +50 -0
  68. litesuite_rust_sidecar-0.1.0/tests/test_port_busy.py +229 -0
  69. litesuite_rust_sidecar-0.1.0/tests/test_port_reaper.py +114 -0
  70. litesuite_rust_sidecar-0.1.0/tests/test_speech_backends.py +132 -0
  71. litesuite_rust_sidecar-0.1.0/tests/test_speech_guard.py +199 -0
  72. litesuite_rust_sidecar-0.1.0/tests/test_user_env.py +46 -0
  73. litesuite_rust_sidecar-0.1.0/tests/test_yue_backend.py +167 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ahostbr
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.
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.4
2
+ Name: litesuite-rust-sidecar
3
+ Version: 0.1.0
4
+ Summary: The Python engines the Rust Lite apps start beside themselves. This version holds LiteSound's audio engine.
5
+ License-Expression: MIT
6
+ Requires-Python: <3.12,>=3.11
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Provides-Extra: litesound
10
+ Requires-Dist: fastapi>=0.115.0; extra == "litesound"
11
+ Requires-Dist: uvicorn[standard]>=0.34.0; extra == "litesound"
12
+ Requires-Dist: pydantic>=2.0.0; extra == "litesound"
13
+ Requires-Dist: huggingface_hub>=0.28.0; extra == "litesound"
14
+ Requires-Dist: anyio>=4.14.2; extra == "litesound"
15
+ Requires-Dist: certifi>=2026.10.19; extra == "litesound"
16
+ Requires-Dist: idna>=3.15; extra == "litesound"
17
+ Requires-Dist: pillow>=13.0.0; extra == "litesound"
18
+ Requires-Dist: python-multipart>=0.0.31; extra == "litesound"
19
+ Requires-Dist: starlette>=1.3.1; extra == "litesound"
20
+ Requires-Dist: urllib3>=2.8.0; extra == "litesound"
21
+ Dynamic: license-file
22
+
23
+ # litesuite-rust-sidecar
24
+
25
+ The Python engines that the Rust Lite apps start beside themselves, as one package with one
26
+ sub-package per app. Today it holds `litesuite_rust_sidecar.litesound`, LiteSound's audio engine,
27
+ moved from LiteSound's own `python/audio_engine` folder with only its imports changed.
28
+
29
+ Not published to PyPI yet.
30
+
31
+ ## What the move changed
32
+
33
+ Imports go from script-relative (`from backends.musicgen import ...`) to package-relative
34
+ (`from .backends.musicgen import ...`), and the `if __name__ == "__main__"` block of `server.py`
35
+ is now `__main__.py`. The nine HTTP routes, their bodies, the environment variables and every
36
+ backend are unchanged.
37
+
38
+ Start the engine: `python -m litesuite_rust_sidecar.litesound` (uvicorn on 127.0.0.1, port from
39
+ `LITESOUND_PORT`).
40
+
41
+ ## Tests
42
+
43
+ ```
44
+ python -m unittest discover -s tests
45
+ ```
46
+
47
+ They load no model and need no torch.
48
+
49
+ ## Known
50
+
51
+ - When `LITESOUND_MODELS_DIR`, `LITESOUND_LOG_DIR` and the runtime folder variables are not set,
52
+ the engine falls back to folders counted upwards from its own file. The Rust app always sets
53
+ these variables.
54
+ - The launch token (`auth.py`): with `LITESUITE_SIDECAR_TOKEN` set, every request but `/health` needs
55
+ the header `X-LiteSuite-Sidecar-Token`; unset, the engine is open as before.
56
+ - Environments: `litesound/envs.toml` holds the ordered `uv pip` steps of each engine environment,
57
+ and `python -m litesuite_rust_sidecar.envsetup <env> --uv <uv.exe> [--dry-run]` runs them, checks
58
+ the GPU and the imports, and writes `litesound-env.json` only when that passes. `yue` is not
59
+ installable from the package yet (no recorded recipe).
60
+ - MIT (`LICENSE`). The vendored VibeVoice tree keeps its own licence and `PROVENANCE.md`.
@@ -0,0 +1,38 @@
1
+ # litesuite-rust-sidecar
2
+
3
+ The Python engines that the Rust Lite apps start beside themselves, as one package with one
4
+ sub-package per app. Today it holds `litesuite_rust_sidecar.litesound`, LiteSound's audio engine,
5
+ moved from LiteSound's own `python/audio_engine` folder with only its imports changed.
6
+
7
+ Not published to PyPI yet.
8
+
9
+ ## What the move changed
10
+
11
+ Imports go from script-relative (`from backends.musicgen import ...`) to package-relative
12
+ (`from .backends.musicgen import ...`), and the `if __name__ == "__main__"` block of `server.py`
13
+ is now `__main__.py`. The nine HTTP routes, their bodies, the environment variables and every
14
+ backend are unchanged.
15
+
16
+ Start the engine: `python -m litesuite_rust_sidecar.litesound` (uvicorn on 127.0.0.1, port from
17
+ `LITESOUND_PORT`).
18
+
19
+ ## Tests
20
+
21
+ ```
22
+ python -m unittest discover -s tests
23
+ ```
24
+
25
+ They load no model and need no torch.
26
+
27
+ ## Known
28
+
29
+ - When `LITESOUND_MODELS_DIR`, `LITESOUND_LOG_DIR` and the runtime folder variables are not set,
30
+ the engine falls back to folders counted upwards from its own file. The Rust app always sets
31
+ these variables.
32
+ - The launch token (`auth.py`): with `LITESUITE_SIDECAR_TOKEN` set, every request but `/health` needs
33
+ the header `X-LiteSuite-Sidecar-Token`; unset, the engine is open as before.
34
+ - Environments: `litesound/envs.toml` holds the ordered `uv pip` steps of each engine environment,
35
+ and `python -m litesuite_rust_sidecar.envsetup <env> --uv <uv.exe> [--dry-run]` runs them, checks
36
+ the GPU and the imports, and writes `litesound-env.json` only when that passes. `yue` is not
37
+ installable from the package yet (no recorded recipe).
38
+ - MIT (`LICENSE`). The vendored VibeVoice tree keeps its own licence and `PROVENANCE.md`.
@@ -0,0 +1,41 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "litesuite-rust-sidecar"
7
+ version = "0.1.0"
8
+ description = "The Python engines the Rust Lite apps start beside themselves. This version holds LiteSound's audio engine."
9
+ readme = "README.md"
10
+ # The engine runs on CPython 3.11 today (python/.venv is 3.11.9).
11
+ requires-python = ">=3.11,<3.12"
12
+ # MIT (Ryan). An SPDX expression (PEP 639, setuptools >= 77); with it, setuptools refuses the
13
+ # old "License ::" classifier, so none is given.
14
+ license = "MIT"
15
+ license-files = ["LICENSE"]
16
+ # No required dependencies: each app has an extra, and torch and the model libraries are
17
+ # installed per environment by ordered steps, not as dependencies (sub-w6-sidecar.md, C1 and C3).
18
+ dependencies = []
19
+
20
+ [project.optional-dependencies]
21
+ # What LiteSound's server needs to start and answer /health, /status and the hub routes.
22
+ # The floors are those of python/requirements.txt.
23
+ litesound = [
24
+ "fastapi>=0.115.0",
25
+ "uvicorn[standard]>=0.34.0",
26
+ "pydantic>=2.0.0",
27
+ "huggingface_hub>=0.28.0",
28
+ "anyio>=4.14.2",
29
+ "certifi>=2026.10.19",
30
+ "idna>=3.15",
31
+ "pillow>=13.0.0",
32
+ "python-multipart>=0.0.31",
33
+ "starlette>=1.3.1",
34
+ "urllib3>=2.8.0",
35
+ ]
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.package-data]
41
+ "litesuite_rust_sidecar.litesound" = ["vendor/**/*", "envs.toml"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """The Python engines of the Rust Lite apps. One sub-package per app."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,51 @@
1
+ """The launch token (C4): nothing on the PC but the app that started an engine can drive it.
2
+
3
+ The parent app makes 32 random bytes per run, hex-encoded, and passes them to every engine it
4
+ starts in `LITESUITE_SIDECAR_TOKEN`. With that variable set, a request without the header
5
+ `X-LiteSuite-Sidecar-Token: <token>` (compared in constant time) is answered 401
6
+ `{"detail": "missing or wrong sidecar token"}`, except `/health`, which answers `{"ok": true}` and
7
+ nothing more. With the variable unset (an engine started by hand, or an app that does not pass
8
+ one), the engine behaves exactly as before.
9
+
10
+ This is security, not licensing. The token is read from the environment on each request, so it is
11
+ never written anywhere by the engine.
12
+ """
13
+ from __future__ import annotations
14
+
15
+ import hmac
16
+ import json
17
+ import os
18
+
19
+ TOKEN_VAR = "LITESUITE_SIDECAR_TOKEN"
20
+ HEADER = b"x-litesuite-sidecar-token"
21
+ REFUSED = {"detail": "missing or wrong sidecar token"}
22
+
23
+
24
+ class SidecarToken:
25
+ """ASGI middleware: wraps the whole app, so every route, present or future, is covered."""
26
+
27
+ def __init__(self, app):
28
+ self.app = app
29
+
30
+ async def __call__(self, scope, receive, send):
31
+ token = os.environ.get(TOKEN_VAR, "")
32
+ if scope["type"] != "http" or not token:
33
+ await self.app(scope, receive, send)
34
+ return
35
+ given = b""
36
+ for name, value in scope.get("headers", []):
37
+ if name.lower() == HEADER:
38
+ given = value
39
+ if hmac.compare_digest(given, token.encode("utf-8")):
40
+ await self.app(scope, receive, send)
41
+ return
42
+ if scope.get("path") == "/health":
43
+ await _json(send, 200, {"ok": True})
44
+ else:
45
+ await _json(send, 401, REFUSED)
46
+
47
+
48
+ async def _json(send, status: int, body: dict) -> None:
49
+ data = json.dumps(body, separators=(",", ":")).encode("utf-8")
50
+ await send({"type": "http.response.start", "status": status, "headers": [(b"content-type", b"application/json"), (b"content-length", str(len(data)).encode())]})
51
+ await send({"type": "http.response.body", "body": data})
@@ -0,0 +1,135 @@
1
+ """Builds one engine environment by its recipe (C3), from inside that environment.
2
+
3
+ The app has already made the environment (`uv venv --python 3.11 <env>`) and installed this
4
+ package into it (`uv pip install litesuite-rust-sidecar[litesound]==<version>`). This runs the
5
+ recipe's ordered `uv pip` steps, then the verify program, and writes `litesound-env.json` in the
6
+ environment only if verify passed, so a failed or cancelled build counts as not installed.
7
+
8
+ python -m litesuite_rust_sidecar.envsetup <env> --uv <path to uv.exe> [--app litesound] [--dry-run]
9
+
10
+ `--dry-run` prints the exact commands in order and runs none of them.
11
+ """
12
+ from __future__ import annotations
13
+
14
+ import argparse
15
+ import hashlib
16
+ import json
17
+ import subprocess
18
+ import sys
19
+ import tomllib
20
+ from datetime import datetime, timezone
21
+ from importlib import metadata
22
+ from pathlib import Path
23
+
24
+ PACKAGE = Path(__file__).resolve().parent
25
+ MARKER = "litesound-env.json"
26
+
27
+ # The GPU check of LiteSound's setup_speech_envs.py. torch.cuda.is_available() is not the test: it
28
+ # is True on a build with no kernels for this card. The device's own compute capability must be in
29
+ # torch.cuda.get_arch_list() and a real kernel must run. It touches the GPU for a moment and loads
30
+ # no model.
31
+ GPU_PROBE = r"""
32
+ import torch, sys
33
+ if not torch.cuda.is_available():
34
+ print("WARN no CUDA device visible; backends will run on CPU")
35
+ sys.exit(0)
36
+ cap = "sm_%d%d" % torch.cuda.get_device_capability(0)
37
+ arches = torch.cuda.get_arch_list()
38
+ name = torch.cuda.get_device_name(0)
39
+ if cap not in arches:
40
+ print("FAIL %s is %s but this torch (%s) builds only %s" % (name, cap, torch.__version__, arches))
41
+ sys.exit(1)
42
+ x = torch.randn(512, 512, device="cuda")
43
+ float((x @ x).sum())
44
+ print("%s %s | torch %s" % (name, cap, torch.__version__))
45
+ """
46
+
47
+
48
+ def recipes(app: str = "litesound") -> dict:
49
+ return tomllib.loads((PACKAGE / app / "envs.toml").read_text(encoding="utf-8"))["envs"]
50
+
51
+
52
+ def recipe(env: str, app: str = "litesound") -> dict:
53
+ envs = recipes(app)
54
+ if env not in envs:
55
+ raise SystemExit(f"no environment {env!r} in {app}'s recipes: {', '.join(envs)}")
56
+ found = envs[env]
57
+ if found.get("checkout_only"):
58
+ raise SystemExit(f"{env}: {found.get('reason', 'not installable from the package')}")
59
+ return found
60
+
61
+
62
+ def commands(env: str, uv: str, python: str, app: str = "litesound") -> list[list[str]]:
63
+ """The `uv pip` commands of the recipe, in order, for the interpreter `python`."""
64
+ found = recipe(env, app)
65
+ index = found.get("torch_index", "")
66
+ out = []
67
+ for step in found["steps"]:
68
+ args = [a.replace("{torch_index}", index) for a in step]
69
+ out.append([uv, "pip", args[0], "--python", python, *args[1:]])
70
+ return out
71
+
72
+
73
+ def verify(env: str, python: str, app: str = "litesound") -> tuple[bool, str]:
74
+ """The GPU check, then the recipe's import check. Returns (passed, the last line said)."""
75
+ found = recipe(env, app)
76
+ gpu = subprocess.run([python, "-c", GPU_PROBE], capture_output=True, text=True)
77
+ said = (gpu.stdout or gpu.stderr).strip().splitlines()
78
+ detail = said[-1] if said else "no output"
79
+ if gpu.returncode != 0:
80
+ return False, detail
81
+ program = found.get("verify", "")
82
+ if program:
83
+ program = program.replace("{vendor}", str(PACKAGE / app / "vendor"))
84
+ imported = subprocess.run([python, "-c", program], capture_output=True, text=True)
85
+ if imported.returncode != 0:
86
+ last = (imported.stderr or "").strip().splitlines()
87
+ return False, f"import failed: {last[-1] if last else 'unknown'}"
88
+ return True, detail
89
+
90
+
91
+ def recipes_sha256(app: str = "litesound") -> str:
92
+ """The SHA-256 of the app's envs.toml as shipped: the app compares it with the one it was
93
+ built against and reports an environment built from other recipes as needing an update."""
94
+ return hashlib.sha256((PACKAGE / app / "envs.toml").read_bytes()).hexdigest()
95
+
96
+
97
+ def marker_body(env: str, version: str, app: str, detail: str) -> dict:
98
+ """`litesound-env.json` (C2): written last, only after verify passed."""
99
+ return {"env": env, "package_version": version, "recipe_sha256": recipes_sha256(app), "built_at": datetime.now(timezone.utc).isoformat(timespec="seconds"), "verify": "ok", "gpu": detail}
100
+
101
+
102
+ def main(argv: list[str] | None = None) -> int:
103
+ parser = argparse.ArgumentParser(prog="python -m litesuite_rust_sidecar.envsetup")
104
+ parser.add_argument("env")
105
+ parser.add_argument("--uv", required=True, help="the uv.exe the app ships")
106
+ parser.add_argument("--app", default="litesound")
107
+ parser.add_argument("--dry-run", action="store_true", help="print the commands in order; run nothing")
108
+ args = parser.parse_args(argv)
109
+ python = sys.executable
110
+ steps = commands(args.env, args.uv, python, args.app)
111
+ if args.dry_run:
112
+ for step in steps:
113
+ print(subprocess.list2cmdline(step))
114
+ return 0
115
+ marker = Path(sys.prefix) / MARKER
116
+ marker.unlink(missing_ok=True)
117
+ for i, step in enumerate(steps, 1):
118
+ print(f"[{i}/{len(steps)}] {subprocess.list2cmdline(step)}", flush=True)
119
+ if subprocess.run(step).returncode != 0:
120
+ print(f"FAILED at step {i}", flush=True)
121
+ return 1
122
+ passed, detail = verify(args.env, python, args.app)
123
+ print(("verified: " if passed else "verify FAILED: ") + detail, flush=True)
124
+ if not passed:
125
+ return 1
126
+ try:
127
+ version = metadata.version("litesuite-rust-sidecar")
128
+ except metadata.PackageNotFoundError:
129
+ version = "unknown"
130
+ marker.write_text(json.dumps(marker_body(args.env, version, args.app, detail), indent=2), encoding="utf-8")
131
+ return 0
132
+
133
+
134
+ if __name__ == "__main__":
135
+ sys.exit(main())
@@ -0,0 +1,10 @@
1
+ """`python -m litesuite_rust_sidecar.litesound`: LiteSound's audio engine on 127.0.0.1.
2
+
3
+ This is the `if __name__ == "__main__"` block of server.py, moved here unchanged in what it does.
4
+ """
5
+ import uvicorn
6
+
7
+ from .server import PORT, app
8
+
9
+ if __name__ == "__main__":
10
+ uvicorn.run(app, host="127.0.0.1", port=PORT, log_level="info")
@@ -0,0 +1,118 @@
1
+ """ACE-Step GGUF quant-profile manifest for LiteSound.
2
+
3
+ Every profile shares the embedding (Q8) + VAE (BF16) and differs only in the LM +
4
+ synth quant. ace-server loads models by filename per request, so all installed
5
+ profiles can coexist in one models dir and the active one is just a filename choice.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ from dataclasses import dataclass
11
+ from pathlib import Path
12
+ from typing import Iterable, Optional
13
+
14
+ from .model_paths import models_dir
15
+
16
+
17
+ REPO_ID = "Serveurperso/ACE-Step-1.5-GGUF"
18
+ BACKEND_ID = "ace-step-gguf"
19
+
20
+
21
+ @dataclass(frozen=True)
22
+ class GgufFile:
23
+ name: str
24
+ size: int
25
+
26
+
27
+ # Shared by every profile (constant across quants)
28
+ SHARED_FILES: tuple[GgufFile, ...] = (
29
+ GgufFile("Qwen3-Embedding-0.6B-Q8_0.gguf", 784_144_960),
30
+ GgufFile("vae-BF16.gguf", 337_420_928),
31
+ )
32
+
33
+
34
+ @dataclass(frozen=True)
35
+ class GgufProfile:
36
+ id: str
37
+ label: str
38
+ lm_model: str
39
+ synth_model: str
40
+ lm_size: int
41
+ synth_size: int
42
+
43
+ @property
44
+ def files(self) -> tuple[GgufFile, ...]:
45
+ return (
46
+ GgufFile(self.lm_model, self.lm_size),
47
+ GgufFile(self.synth_model, self.synth_size),
48
+ ) + SHARED_FILES
49
+
50
+ @property
51
+ def total_bytes(self) -> int:
52
+ return sum(f.size for f in self.files)
53
+
54
+
55
+ # Ordered max-quality -> smallest. Sizes are exact (the installer verifies them).
56
+ PROFILES: tuple[GgufProfile, ...] = (
57
+ GgufProfile("q8-turbo-4b", "Q8 Turbo 4B · Max quality",
58
+ "acestep-5Hz-lm-4B-Q8_0.gguf", "acestep-v15-turbo-Q8_0.gguf",
59
+ 4_457_323_648, 2_549_528_000),
60
+ GgufProfile("q6-turbo-4b", "Q6_K Turbo 4B · Near-lossless",
61
+ "acestep-5Hz-lm-4B-Q6_K.gguf", "acestep-v15-turbo-Q6_K.gguf",
62
+ 3_442_713_504, 1_970_472_064),
63
+ GgufProfile("q5-turbo-4b", "Q5_K_M Turbo 4B · Balanced",
64
+ "acestep-5Hz-lm-4B-Q5_K_M.gguf", "acestep-v15-turbo-Q5_K_M.gguf",
65
+ 3_025_965_984, 1_700_140_224),
66
+ GgufProfile("q5q4-turbo-4b", "Q5/Q4 Turbo 4B · Smallest",
67
+ "acestep-5Hz-lm-4B-Q5_K_M.gguf", "acestep-v15-turbo-Q4_K_M.gguf",
68
+ 3_025_965_984, 1_445_710_272),
69
+ )
70
+ # Smallest quant is the default: instrumental generation is ~indistinguishable
71
+ # from Q8 by ear, ~33% faster, ~31% smaller. Bump to Q8/Q6 via the dropdown for
72
+ # vocal/lyric work, where quantization hurts intelligibility more.
73
+ DEFAULT_PROFILE_ID = "q5q4-turbo-4b"
74
+
75
+
76
+ def get_profile(profile_id: Optional[str]) -> GgufProfile:
77
+ target = profile_id or DEFAULT_PROFILE_ID
78
+ for p in PROFILES:
79
+ if p.id == target:
80
+ return p
81
+ return PROFILES[0]
82
+
83
+
84
+ def default_models_dir() -> Path:
85
+ override = os.environ.get("LITESOUND_ACESTEP_GGUF_MODELS_DIR")
86
+ return Path(override) if override else models_dir() / BACKEND_ID
87
+
88
+
89
+ def default_runtime_dir() -> Path:
90
+ return Path(__file__).resolve().parents[2] / "bin" / "runtime" / "acestep.cpp"
91
+
92
+
93
+ def profile_installed(models_dir: Path | None = None,
94
+ profile: GgufProfile | str | None = None) -> bool:
95
+ root = models_dir or default_models_dir()
96
+ prof = profile if isinstance(profile, GgufProfile) else get_profile(profile)
97
+ for file in prof.files:
98
+ path = root / file.name
99
+ if not path.is_file() or path.stat().st_size != file.size:
100
+ return False
101
+ return True
102
+
103
+
104
+ def iter_profile_files(profile: GgufProfile | str | None = None) -> Iterable[GgufFile]:
105
+ prof = profile if isinstance(profile, GgufProfile) else get_profile(profile)
106
+ return prof.files
107
+
108
+
109
+ # ── Back-compat single-profile aliases (track the active default) ─────────────
110
+ _DEFAULT = get_profile(None)
111
+ PROFILE_ID = _DEFAULT.id
112
+ PROFILE_LABEL = _DEFAULT.label
113
+ TOTAL_BYTES = _DEFAULT.total_bytes
114
+ LM_MODEL = "acestep-5Hz-lm-4B-Q8_0"
115
+ SYNTH_MODEL = "acestep-v15-turbo-Q8_0"
116
+ LM_MODEL_FILE = _DEFAULT.lm_model
117
+ SYNTH_MODEL_FILE = _DEFAULT.synth_model
118
+ PROFILE_FILES = _DEFAULT.files