Skip to content

Free, open-source AI video generator for Mac. Run LTX-2.5 and MiniMax H3 (Hailuo) locally on Apple Silicon: text-to-video and image-to-video with sound, lip-sync, character LoRA training, songs from lyrics (YuE2) and image editing (Qwen-Image-Edit). One-click install via Pinokio. Offline: no cloud, no API key, no NVIDIA GPU.

release(v4.15.2): lip-sync on LTX audio-to-video now actually follows the audio

mrbizarro59d733ddc5e2
diff --git a/README.md b/README.md
index f2e8ace..36b4ea7 100644
--- a/README.md
+++ b/README.md
@@ -19,7 +19,7 @@
</p>
-> **Current release: v4.15.1.** **The install fixes.** ffmpeg is found where Pinokio actually puts it, so a render that finished no longer fails to export. A **half-built engine environment** is caught at boot with a one-click repair instead of failing 30 seconds into every render. **Hailuo H3 checks its MLX before it starts** rather than dying eight minutes in. Captioning tells you when it was pointed at LTX-2.5's text encoder instead of the vision model. Under the hood, the panel now reports **which step of getting started failed** — because 55% of new installs never render and nothing said why. See [what is collected](docs/ANALYTICS.md). Full notes on the [releases page](https://github.com/mrbizarro/Phosphene/releases).
+> **Current release: v4.15.2.** **Lip-sync on LTX audio-to-video now actually follows the audio.** Since v4.8.1 the Audio tab's *Audio conditioning strength* started at 1.0 — and on the Q8 pipeline 1.0 switches audio guidance **off**, so the mouth moved without tracking the song. The slider now starts on **Auto** (the engine's own setting for your Mac: 3.0 on Q8, 1.0 on Q4), and a value you set by hand is kept exactly. Q8 audio-to-video renders take about a quarter longer again, because the audio pass that was being skipped runs. Also: the Pinokio sidebar now offers **Repair Phosphene engine** when the engine package never finished installing — promised in 4.15.1, delivered here. Full notes on the [releases page](https://github.com/mrbizarro/Phosphene/releases).
## Overview
diff --git a/VERSION b/VERSION
index fb05571..3e2accd 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.15.1
+4.15.2
diff --git a/docs/STATE.md b/docs/STATE.md
index b5c5f10..da995d1 100644
--- a/docs/STATE.md
+++ b/docs/STATE.md
@@ -1,5 +1,17 @@
# Phosphene — project state, history, open work
+> **🎤 2026-09-22 — v4.15.2: lip-sync on LTX audio-to-video follows the audio again.** The owner saw the improved lip-sync on the study's shot and ordered it shipped, because LTX lip-sync was not good. The order covered the lip-sync fix and nothing else from dev.
+>
+> **The bug was a number with two meanings.** The Audio tab's *Audio conditioning strength* feeds two pipelines. Q4 distilled multiplies the audio tokens by it, so 1.0 is the identity and audio is fully on. The Q8 two-stage pipeline has no such parameter; since **v4.8.1** the helper reroutes the slider onto the stage-1 guider's `modality_scale`, whose term is `(value − 1) × (cond − uncond_modality)` — at **1.0 exactly zero**. The engine's own value there is 3.0, which is also what every Q8 a2v render used before 4.8.1 (the slider was being dropped by the kwarg filter then). `make_job` stamped 1.0 on every job and the slider started at 1.0, so every Q8 a2v clip rendered at the default since 4.8.1 had audio guidance switched off.
+>
+> **What shipped.** `make_job` no longer fabricates a number; `a2v_audio_scale()` resolves a blank to the lane's own value (Q8 3.0, Q4 1.0) in the a2v branch, against `uses_q8`, so the Q8→Q4 fallback gets the Q4 value. Explicit values pass through on both lanes; `nan`/`inf`/`<= 0` fall back. The slider starts on **Auto** and sends nothing until dragged. The run log says `scale=3.0 (Q8 default)`, and the sidecar records `audio_conditioning_scale_used`. The helper's Q4 branch got the same `<= 0` guard (a negative value used to flip the sign of every audio token). **Jobs saved by 4.15.1** carry the old default as a float 1.0 and survive Update in the saved queue, and `/queue/retry` copies params verbatim. `a2v_requested_scale()` reads a float 1.0 as "no request". Today's `make_job` only stores strings, so a float can only come from an old job, and a new job that sends `"1.0"` keeps 1.0. **Also shipped:** the `pinokio.js` probe that offers *Repair Phosphene engine (models kept)* when the venv has an interpreter but no `ltx_pipelines_mlx`. 4.15.1's notes and its `test_engine_env_fault` announced it, but the edit sat in the dev checkout under `skip-worktree` and never reached a commit. The test was failing in the public 4.15.1 tree.
+>
+> **Deliberately not shipped** (dev has them, the next minor can carry them): the vocal-stem seam and `scripts/pinokio/a2v_stems_deps.sh`, the a2v prompt rules, and face-tight casting. The stem needs demucs + torch (~2.5 GB) pip-installed into the engine venv; the installer has never been run and has no in-app surface. The prompt rules live in the storyboard planner and `music_video.py`, which public users cannot reach with a2v (`music_video.py` is not on public main, and the public planner never emits a2v). Face-tight casting belongs to the music-video planner.
+>
+> **Validation.** Codex, one pass, two findings, both fixed: P2 was the saved-job case above, P3 was a test that passed on the parser's name alone. The helper parsers are now ast-extracted and executed, and `run_job_inner`'s a2v branch is driven for real with a stub helper across new/legacy × Auto/explicit × Q8/Q4; a mutation that drops the legacy rule fails it. Gates `--fast`: **111 pass, 1 fail, 2 skip**. The fail is `assert_registry.py`, and all eight of its failing asserts are about **LTX-2.3 packs, which this Mac no longer has**. They fail identically on an untouched v4.15.1 worktree run the same way. `test_storyboard_editor_ui` (466 tests) and `check_output_codec` (on the validation clip) ran separately and both pass. Clean room: a fresh clone of public **v4.15.1**, install.js's engine steps under a Pinokio-8.2.0-shaped env with empty caches, then **Update run the way update.js runs it**. It pulled 4.15.2, and `post_update` fetched the LTX-2.5 Q4 pack and text encoder from zero. The Q8 pack was linked because this release does not touch weights. It booted under `PYTORCH_ENABLE_MPS_FALLBACK=1 PYTORCH_MPS_FAST_MATH=1` with no `SSH_*`/`PYTHONPATH`: `/version` 4.15.2, not dirty, Auto slider served. One real a2v render through `/queue/add` with no scale field (the study's reference shot: same image, 10.05 s window from 8.4167 s, seed 1901872887, 1024×576, 241 f) logged `scale=3.0 (Q8 default)` and `modality_scale=3.00`. It took **23.5 min against 18.7 min** for the same shot at the old default, because the audio pass that 1.0 skipped runs again. The video stream is **bit-identical** (PSNR ∞) to the study's acs-3.0 render the owner judged.
+>
+> **The metric, honestly.** On the study's scorer (mouth aperture vs vocal-band envelope, per-second, best lag) the old default scores **−0.065** and 4.15.2 scores **+0.128**, exactly as the study found. But the study's negative control does not hold for music. It scored the clip against the song shifted +3 s, and at ~143 BPM two bars are 3.34 s, inside the ±0.4 s lag search. Scored that way, the new clip gets **+0.366**. The proper null scores each clip against **every** 10.05 s window of the song. Against that null, neither number is distinguishable from chance on one 10 s clip. Full mix: old −0.065 vs null +0.077±0.091 (z −1.55), new +0.128 vs +0.118±0.095 (z +0.10). Demucs vocal stem: old −0.088 (z −1.43), new +0.175 (z +0.56). The direction holds, but the proof is the mechanism (a zero guidance term) and the owner's eye, not this number. A lip-sync metric that can prove itself needs more clips or a SyncNet-class model.
+>
> **🔧 2026-09-20 — v4.15.1: the fleet's own bug list, fixed. Five faults, every one of them found in the data rather than reported.** The owner's instruction was "check fleet, github and pinokio and solve all bugs, ship fixes together with analytics improvements". GitHub and Pinokio turned out to be almost clean — every open bug thread there is already fixed and waiting on a reporter to confirm (the H3 Q8 SIGKILL in 4.12.2, the dead `madebyollin/taeh3` repo in 4.12.x, the YuE2 MPS flags in 4.14.3, the 48 GB bf16 pick in 4.12.4). **The fleet was not clean**, and nobody had filed any of this.
>
> - **ffmpeg was never where we looked.** Five installs across 4.5.0 → 4.15.0 finished a render and failed the export with "ffmpeg not found on PATH". Every engine spawn has prepended `FFMPEG_BIN` to the child's PATH for months — the miss was one level up: `_resolve_ffmpeg()` knew `pinokio/bin/ffmpeg-env` and nothing else, while **Pinokio's own bootstrap installs `ffmpeg=8.1.2` into its conda prefix** (`bin/miniforge/bin`) and unpacks a private Homebrew beside it. Proven on this Mac: that binary is sitting at `~/pinokio/bin/miniforge/bin/ffmpeg`, 443 KB, dated August. Now searched, along with `bin/miniconda/bin` and `bin/homebrew/bin`; **ffprobe resolves independently** instead of assuming the sibling path exists (the fleet's bare "ffprobe failed:", 3 installs); and a boot warning names every folder that was searched.
diff --git a/mlx_ltx_panel.py b/mlx_ltx_panel.py
index 941649a..ddf4a94 100644
--- a/mlx_ltx_panel.py
+++ b/mlx_ltx_panel.py
@@ -23716,6 +23716,69 @@ PASTED_PATH_FIELDS = (
)
+# --- A2V AUDIO GUIDANCE: THE TWO LANES DISAGREE ABOUT WHAT 1.0 MEANS --------
+# One slider, two engines, opposite meanings at the same number.
+#
+# Q4 distilled (`a2vid_distilled.py:154`) multiplies the audio TOKENS by the
+# value, so 1.0 is the identity — neutral, and the audio is fully on.
+# Q8 two-stage has no such parameter at all; `mlx_warm_helper` reroutes the
+# slider into the stage-1 guider's `modality_scale`, whose term is
+# `(modality_scale - 1) * (cond - uncond_modality)` (ltx-core-mlx guiders.py).
+# At 1.0 that term is EXACTLY ZERO — the model is told to ignore the audio.
+# The vendored engine's own default there is 3.0.
+#
+# The panel stamped 1.0 on every a2v job, so every Q8 a2v clip this panel has
+# ever rendered at the default had audio guidance switched off in all but name.
+# Measured on one shot with the image, audio window, prompt and seed held
+# fixed, the per-second correlation between the inner-lip aperture and the
+# vocal-band energy went from -0.065 (worse than the same clip scored against
+# deliberately WRONG audio) to +0.128 by changing this number alone.
+#
+# So the default is now the lane's own neutral-but-ON value, and an explicit
+# value is passed through untouched — a saved job, a board or an API caller
+# that names a number keeps that number on both lanes.
+A2V_AUDIO_SCALE_ON = {"q8": 3.0, "q4": 1.0}
+
+
+def a2v_audio_scale(raw, *, q8: bool) -> float:
+ """The audio-guidance value for this lane: `raw` when it names one, else
+ the lane's engine default.
+
+ Blank / absent / unparseable / <= 0 all mean "the engine's own default",
+ which is the same rule `mlx_warm_helper._a2v_modality_scale_value` applies
+ one level down — stated here too because this is the layer that knows
+ WHICH LANE is about to run, and the helper never can.
+ """
+ lane = "q8" if q8 else "q4"
+ try:
+ value = float(str(raw).strip())
+ except (TypeError, ValueError):
+ return A2V_AUDIO_SCALE_ON[lane]
+ # nan/inf parse as floats; neither is a guidance scale a caller meant.
+ if not math.isfinite(value) or value <= 0:
+ return A2V_AUDIO_SCALE_ON[lane]
+ return value
+
+
+def a2v_requested_scale(params: dict):
+ """What the job ASKED for, with the one legacy value read as "no request".
+
+ Jobs made by v4.15.1 and earlier carry the old make_job's fabricated
+ default as a FLOAT 1.0 (it parsed the field with float() and a "1.0"
+ fallback) on every job, and the old slider sent 1.0 unless dragged. Those
+ jobs survive an Update in the saved queue, and /queue/retry copies them
+ verbatim, so honouring that 1.0 would keep audio guidance OFF on Q8 for
+ exactly the renders this fix is for. Today's make_job never stores a
+ float (form fields are strings: "" for Auto, "2.5" when a value was
+ sent), so a float 1.0 can only be the old default and is treated as
+ blank. Any other legacy float was a deliberate drag and is kept.
+ """
+ raw = params.get("audio_conditioning_scale")
+ if isinstance(raw, float) and raw == 1.0:
+ return ""
+ return raw
+
+
def make_job(form: dict[str, list[str]] | dict[str, str], *,
override_prompt: str | None = None) -> dict:
def f(name: str, default: str = "") -> str:
@@ -24624,7 +24687,13 @@ def make_job(form: dict[str, list[str]] | dict[str, str], *,
# 48-79 GB tier to dodge boundary OOM). User can override
# explicitly to "full" or "off" via this form field.
"stage2_image_conditioning": f("stage2_image_conditioning", "") or "",
- "audio_conditioning_scale": float(f("audio_conditioning_scale", "1.0") or 1.0),
+ # NOT defaulted to a number here, and that is the fix: a blank
+ # means "the lane's engine default" and is resolved by
+ # `a2v_audio_scale()` in the a2v branch, which is the only place
+ # that knows whether Q8 or Q4 is about to run. Stamping 1.0 here
+ # is what switched audio guidance OFF on every Q8 a2v render.
+ # A value the caller actually sent survives untouched.
+ "audio_conditioning_scale": f("audio_conditioning_scale", ""),
# Where in the source file A2V starts reading. Both pipelines
# (a2vid_two_stage / a2vid_distilled) have taken this since they
# landed, and mlx_warm_helper forwards it on both actions — the
@@ -29592,7 +29661,8 @@ def run_job_inner(job: dict) -> None:
"seed": p["seed"],
"stage1_steps": int(p.get("stage1_steps", default_stage1)),
"stage2_steps": int(p.get("stage2_steps", default_stage2)),
- "audio_conditioning_scale": float(p.get("audio_conditioning_scale", 1.0)),
+ "audio_conditioning_scale": a2v_audio_scale(
+ a2v_requested_scale(p), q8=uses_q8),
# Offset into the source audio. The helper reads this key on both
# the Q8 and the Q4-distilled action and hands it to
# load_audio(start_time=…); it defaulted to 0.0 here only because
@@ -29610,12 +29680,19 @@ def run_job_inner(job: dict) -> None:
_start_note = ""
if a2v_params["audio_start_time"]:
_start_note = " start=%.2fs" % a2v_params["audio_start_time"]
+ # Say whose number this is. A user who never touched the slider used to
+ # read "scale=1.0" and have no way to know that on this lane 1.0 means
+ # the audio is ignored; now the line names the lane's default as a
+ # default, so the one number that decides whether the mouth moves is
+ # never anonymous.
+ _scale_note = "" if str(a2v_requested_scale(p) or "").strip() \
+ else " (%s default)" % ("Q8" if uses_q8 else "Q4")
push(
f"Run A2V ({'Q8' if uses_q8 else 'Q4-distilled'}) via helper: "
f"id={job['id']} {width}x{height} {frames}f · "
f"audio={Path(audio_src).name}"
f"{' image=' + Path(ref_image_path).name if ref_image_path else ''}"
- f" scale={a2v_params['audio_conditioning_scale']}"
+ f" scale={a2v_params['audio_conditioning_scale']}{_scale_note}"
f"{_start_note}"
)
result = HELPER.run(job_spec)
@@ -29626,6 +29703,12 @@ def run_job_inner(job: dict) -> None:
"output": str(out_path), "raw_output": str(out_path),
"params": {**p, "command": action, "audio": audio_src,
"image": ref_image_path},
+ # The number the engine actually ran with. `params` keeps what
+ # the caller sent — blank when the slider was on Auto — so a
+ # re-run resolves against its own lane again; this line is the
+ # record of which lane default a clip was rendered at.
+ "audio_conditioning_scale_used":
+ a2v_params["audio_conditioning_scale"],
"started": job.get("started_at"),
"elapsed_sec": round(time.time() - job["started_ts"], 2)
if job.get("started_ts") else None,
diff --git a/mlx_warm_helper.py b/mlx_warm_helper.py
index 3b55bc0..3e6d3ad 100644
--- a/mlx_warm_helper.py
+++ b/mlx_warm_helper.py
@@ -254,7 +254,16 @@ _A2V_STATE = {"modality_scale": None}
def _a2v_modality_scale_value(raw):
"""Parse the slider off the job params: '14.0' -> 14.0; ''/None/0/'0'/
- garbage/negative -> None (= keep the engine's own 3.0 default)."""
+ garbage/negative -> None (= keep the engine's own 3.0 default).
+
+ THE LANE DEFAULT IS NOT DECIDED HERE and cannot be: this function is the
+ Q8 half of a slider the Q4 pipeline reads with the opposite meaning at 1.0
+ (there it multiplies the audio tokens, so 1.0 is the identity; here it is
+ `(modality_scale - 1) * …`, so 1.0 is ZERO audio). The panel knows which
+ pipeline is about to run and resolves the default before the job is sent —
+ `mlx_ltx_panel.a2v_audio_scale()`. Blank still means "the engine's own
+ default" here, so a hand-written job spec that names nothing is safe.
+ """
try:
value = float(raw or 0)
except (TypeError, ValueError):
@@ -262,6 +271,17 @@ def _a2v_modality_scale_value(raw):
return value if value > 0 else None
+def _a2v_distilled_scale_value(raw) -> float:
+ """The Q4 distilled lane's audio_conditioning_scale: a positive number, or
+ 1.0 (its identity) when the job names nothing usable. A negative value used
+ to reach the DiT and flip the sign of every audio token."""
+ try:
+ value = float(str(raw).strip())
+ except (TypeError, ValueError):
+ return 1.0
+ return value if value > 0 else 1.0
+
+
def _a2v_stage1_guider_params(guider_params_cls, cfg_scale, stg_scale):
"""The (video, audio) guider params for a2v stage 1, exactly as the
vendored `_denoise_stage1` builds them — except `modality_scale` reads
@@ -3939,8 +3959,13 @@ for line in sys.__stdin__:
# before the DiT. Its denoise is plain `denoise_loop` — no
# guiders — so the modality_scale patch has nothing to drive
# on this path and must not claim otherwise in the log.
- audio_conditioning_scale=float(
- p.get("audio_conditioning_scale") or 1.0),
+ # Blank / 0 / negative -> 1.0, the identity, which on THIS
+ # pipeline is neutral-and-on (a2vid_distilled.py multiplies the
+ # audio tokens by it). Same "<= 0 means the engine's default"
+ # rule as `_a2v_modality_scale_value` above, so the two lanes
+ # cannot disagree about what a missing value means.
+ audio_conditioning_scale=_a2v_distilled_scale_value(
+ p.get("audio_conditioning_scale")),
)
ref_image = p.get("image") or None
if ref_image:
diff --git a/pinokio.js b/pinokio.js
index c06f64d..1398356 100644
--- a/pinokio.js
+++ b/pinokio.js
@@ -390,7 +390,16 @@ module.exports = {
// what is already on disk. Nothing is re-fetched — hence "models kept".
const ltx_python = onDisk("ltx-2-mlx/env/bin/python3.11") ||
onDisk("ltx-2-mlx/env/bin/python")
- const ltx_repair = env_ready && !ltx_python
+ // ...and the OTHER half-built shape, which used to look perfectly healthy
+ // here (fleet, 2026-09-20): the interpreter is present but the engine
+ // package never landed in it, so every render dies at helper start with
+ // "ModuleNotFoundError: No module named 'ltx_pipelines_mlx'". Three
+ // installs on 4.13.0 / 4.14.3 / 4.15.0 hit it, one of them 28 times in a
+ // row — with no repair offered, because the file this menu looked at was
+ // exactly the file that existed. The package directory is the honest
+ // marker: pip writes it last.
+ const ltx_pkg = onDisk("ltx-2-mlx/env/lib/python3.11/site-packages/ltx_pipelines_mlx")
+ const ltx_repair = env_ready && (!ltx_python || !ltx_pkg)
const pushLtxRepair = (m) => {
if (ltx_repair) {
m.push({ icon: "fa-solid fa-screwdriver-wrench",
diff --git a/test_a2v_audio_adhesion.py b/test_a2v_audio_adhesion.py
index fdbe15b..ee9b7e4 100644
--- a/test_a2v_audio_adhesion.py
+++ b/test_a2v_audio_adhesion.py
@@ -251,7 +251,9 @@ class DistilledPathStaysNative(unittest.TestCase):
self.assertEqual(
src.count('_A2V_STATE["modality_scale"] = _a2v_modality_scale_value('),
1)
- self.assertIn("audio_conditioning_scale=float(", src)
+ # The distilled branch parses the value with its OWN <= 0 guard
+ # (`_a2v_distilled_scale_value`) rather than the guider staging.
+ self.assertIn("audio_conditioning_scale=_a2v_distilled_scale_value(", src)
if __name__ == "__main__":
diff --git a/test_a2v_sync_fixes.py b/test_a2v_sync_fixes.py
new file mode 100644
index 0000000..2a63322
--- /dev/null
+++ b/test_a2v_sync_fixes.py
@@ -0,0 +1,252 @@
+"""The a2v lip-sync fix — audio guidance defaults to the lane's own value.
+
+Measured on one shot, at one seed, with the image, the audio window and the
+prompt held fixed: the per-second correlation between the mouth's aperture and
+the vocal-band energy of the soundtrack went **-0.065 -> +0.128** by changing
+the audio-guidance default alone. -0.065 is worse than the same clip scored
+against deliberately WRONG audio, i.e. the old default was not lip-syncing at
+all on the Q8 lane.
+
+Structural assertions (reading a source file rather than running a render) are
+used where the alternative is a GPU: the a2v branch of `run_job_inner` needs a
+weights pack, a helper subprocess and twenty minutes. They are written against
+the exact line that decides the behaviour, never against prose.
+"""
+
+import unittest
+from pathlib import Path
+
+import mlx_ltx_panel as P
+
+PANEL_SRC = Path(__file__).with_name("mlx_ltx_panel.py").read_text()
+HELPER_SRC = Path(__file__).with_name("mlx_warm_helper.py").read_text()
+INDEX_HTML = Path(__file__).with_name("webapp") / "index.html"
+CHARACTERS_JS = Path(__file__).with_name("webapp") / "js" / "characters.js"
+
+
+def _helper_functions(*names):
+ """Exec the named top-level functions of mlx_warm_helper.py in isolation."""
+ import ast
+ tree = ast.parse(HELPER_SRC)
+ defs = [n for n in tree.body
+ if isinstance(n, ast.FunctionDef) and n.name in names]
+ assert sorted(d.name for d in defs) == sorted(names), names
+ ns: dict = {}
+ exec(compile(ast.Module(body=defs, type_ignores=[]), "mlx_warm_helper.py",
+ "exec"), ns)
+ return ns
+
+
+# ---------------------------------------------------------------------------
+# 1. THE LANE-AWARE AUDIO-GUIDANCE DEFAULT
+# ---------------------------------------------------------------------------
+class LaneAwareAudioScale(unittest.TestCase):
+ """1.0 means "audio fully on" on Q4 and "audio exactly off" on Q8."""
+
+ def test_the_lane_defaults_are_the_engines_own(self):
+ # Q8: the vendored a2vid_two_stage hardcodes modality_scale=3.0.
+ # Q4: a2vid_distilled multiplies the audio tokens, so 1.0 is identity.
+ self.assertEqual(P.A2V_AUDIO_SCALE_ON["q8"], 3.0)
+ self.assertEqual(P.A2V_AUDIO_SCALE_ON["q4"], 1.0)
+
+ def test_a_q8_job_with_no_scale_gets_the_lanes_on_value(self):
+ for raw in (None, "", " "):
+ with self.subTest(raw=raw):
+ self.assertEqual(P.a2v_audio_scale(raw, q8=True), 3.0)
+ self.assertEqual(P.a2v_audio_scale(raw, q8=False), 1.0)
+
+ def test_an_explicit_value_passes_through_unchanged_on_both_lanes(self):
+ for raw in ("0.5", "1.0", 2.5, "5.0"):
+ with self.subTest(raw=raw):
+ self.assertEqual(P.a2v_audio_scale(raw, q8=True), float(raw))
+ self.assertEqual(P.a2v_audio_scale(raw, q8=False), float(raw))
+
+ def test_garbage_and_nonpositive_fall_back_to_the_lane(self):
+ # Same rule the helper applies one level down: <= 0 means "the
+ # engine's own default", never a negative multiplier on audio tokens.
+ for raw in ("banana", "0", 0, -1, "-3.0", [], {}, "nan", "inf", "-inf"):
+ with self.subTest(raw=raw):
+ self.assertEqual(P.a2v_audio_scale(raw, q8=True), 3.0)
+ self.assertEqual(P.a2v_audio_scale(raw, q8=False), 1.0)
+
+ def test_make_job_no_longer_fabricates_a_number(self):
+ job = P.make_job({"mode": "a2v", "prompt": "a face", "audio": "/x.wav"})
+ self.assertEqual(job["params"]["audio_conditioning_scale"], "")
+
+ def test_make_job_keeps_a_value_the_caller_sent(self):
+ job = P.make_job({"mode": "a2v", "prompt": "a face", "audio": "/x.wav",
+ "audio_conditioning_scale": "2.5"})
+ self.assertEqual(job["params"]["audio_conditioning_scale"], "2.5")
+
+ def test_the_dispatch_resolves_against_the_lane_it_is_about_to_run(self):
+ # The lane is `uses_q8`, which also carries the Q8->Q4 fallback when
+ # the Q8 surface is missing. Resolving against anything else would put
+ # a 3.0 meant for the guider onto the distilled lane's token multiplier.
+ self.assertIn("a2v_audio_scale(\n a2v_requested_scale(p), q8=uses_q8)",
+ PANEL_SRC)
+
+ def test_the_fabricated_default_cannot_come_back(self):
+ self.assertNotIn('float(f("audio_conditioning_scale"', PANEL_SRC)
+ self.assertNotIn('float(p.get("audio_conditioning_scale", 1.0))', PANEL_SRC)
+
+ def test_the_helper_still_treats_blank_as_the_engine_default(self):
+ # A hand-written job spec that names nothing must stay safe on both
+ # lanes even though the panel now always resolves before sending.
+ # The helper cannot be imported (its main loop reads stdin at module
+ # level), so the two parsers are lifted out of the source and RUN.
+ ns = _helper_functions("_a2v_distilled_scale_value",
+ "_a2v_modality_scale_value")
+ q4 = ns["_a2v_distilled_scale_value"]
+ q8 = ns["_a2v_modality_scale_value"]
+ for raw in (None, "", " ", "0", 0, -2, "-1.5", "banana"):
+ with self.subTest(lane="q4", raw=raw):
+ self.assertEqual(q4(raw), 1.0)
+ with self.subTest(lane="q8", raw=raw):
+ self.assertIsNone(q8(raw)) # None = the engine's own 3.0
+ for raw, want in (("2.5", 2.5), (0.7, 0.7), ("3", 3.0)):
+ with self.subTest(explicit=raw):
+ self.assertEqual(q4(raw), want)
+ self.assertEqual(q8(raw), want)
+ self.assertIn("ms = 3.0 if ms is None else float(ms)", HELPER_SRC)
+ # And the Q4 branch really calls the guarded parser.
+ self.assertIn("audio_conditioning_scale=_a2v_distilled_scale_value(",
+ HELPER_SRC)
+
+ def test_the_sidecar_records_the_number_the_engine_ran_with(self):
+ # `params` keeps the caller's blank (so a re-run resolves against its
+ # own lane again); the resolved value is recorded beside it, so a clip
+ # says which default it was rendered at.
+ self.assertIn('"audio_conditioning_scale_used":\n'
+ ' a2v_params["audio_conditioning_scale"]',
+ PANEL_SRC)
+
+ def test_the_slider_starts_on_auto_and_sends_nothing(self):
+ html = INDEX_HTML.read_text()
+ self.assertIn('id="audioConditioningScale"', html)
+ self.assertIn('data-auto="1"', html)
+ self.assertIn('class="range-val">Auto<', html)
+ js = CHARACTERS_JS.read_text()
+ # The field is set only inside the guard, so an untouched control
+ # cannot send a number the panel would then treat as deliberate.
+ self.assertIn("if (audioConditioningScale !== null", js)
+ self.assertIn("(acsEl && !acsEl.dataset.auto)", js)
+
+
+
+class JobsSavedBeforeTheFix(unittest.TestCase):
+ """A job queued or finished under 4.15.1 carries the old make_job's float
+ 1.0 on every job. It survives Update in the saved queue and /queue/retry
+ copies it verbatim; reading it as a deliberate 1.0 would keep Q8 audio
+ guidance OFF for exactly the renders this fix is for."""
+
+ def test_a_legacy_float_one_is_the_old_default_not_a_choice(self):
+ req = P.a2v_requested_scale({"audio_conditioning_scale": 1.0})
+ self.assertEqual(req, "")
+ self.assertEqual(P.a2v_audio_scale(req, q8=True), 3.0)
+ self.assertEqual(P.a2v_audio_scale(req, q8=False), 1.0)
+
+ def test_a_legacy_float_that_was_dragged_is_kept(self):
+ for raw in (2.5, 0.5, 4.0):
+ with self.subTest(raw=raw):
+ req = P.a2v_requested_scale({"audio_conditioning_scale": raw})
+ self.assertEqual(P.a2v_audio_scale(req, q8=True), raw)
+
+ def test_a_new_job_that_sends_one_point_oh_keeps_it(self):
+ # Today's make_job stores what the form sent, as a STRING, so a user
+ # who drags the slider to 1.0 on purpose gets 1.0.
+ job = P.make_job({"mode": "a2v", "prompt": "a face", "audio": "/x.wav",
+ "audio_conditioning_scale": "1.0"})
+ req = P.a2v_requested_scale(job["params"])
+ self.assertEqual(P.a2v_audio_scale(req, q8=True), 1.0)
+
+ def test_a_new_auto_job_and_a_missing_key_both_resolve_to_the_lane(self):
+ job = P.make_job({"mode": "a2v", "prompt": "a face", "audio": "/x.wav"})
+ for params in (job["params"], {}):
+ with self.subTest(params=params.get("audio_conditioning_scale")):
+ req = P.a2v_requested_scale(params)
+ self.assertEqual(P.a2v_audio_scale(req, q8=True), 3.0)
+
+ def test_make_job_never_stores_a_float(self):
+ # The legacy rule above keys on the TYPE; it is only sound while no
+ # current path stores a float here.
+ for form in ({}, {"audio_conditioning_scale": "2.0"},
+ {"audio_conditioning_scale": "1.0"}):
+ job = P.make_job({"mode": "a2v", "prompt": "p", "audio": "/x.wav",
+ **form})
+ self.assertIsInstance(job["params"]["audio_conditioning_scale"], str)
+
+ def test_the_run_log_calls_a_legacy_default_a_default(self):
+ self.assertIn('_scale_note = "" if str(a2v_requested_scale(p) or "").strip()',
+ PANEL_SRC)
+
+
+
+class TheDispatchSendsTheLaneValue(unittest.TestCase):
+ """Behavioural, not structural: drive the REAL a2v branch of run_job_inner
+ with a stub helper and read the spec it would have sent. No GPU, no weights,
+ no subprocess — the helper, the pack preflight and the sidecar writer are
+ the only things replaced, and all three are restored afterwards."""
+
+ def _dispatch(self, acs, *, q8):
+ import tempfile
+ import time
+ from unittest import mock
+
+ tmp = Path(tempfile.mkdtemp(prefix="a2v-dispatch-"))
+ wav = tmp / "a.wav"
+ wav.write_bytes(b"RIFF0000WAVE")
+ sent, sidecars = [], []
+
+ class _Helper:
+ ready_info: dict = {}
+
+ def is_alive(self):
+ return True
+
+ def kill(self, *a, **k):
+ pass
+
+ def run(self, spec):
+ sent.append(spec)
+ Path(spec["params"]["output_path"]).write_bytes(b"x")
+ return {"seed_used": 1, "elapsed_sec": 0.1}
+
+ params = P.make_job({"mode": "a2v", "prompt": "a singer",
+ "audio": str(wav), "width": "512",
+ "height": "288", "frames": "49"})["params"]
+ if acs is not None:
+ params["audio_conditioning_scale"] = acs
+ caps = dict(P.SYSTEM_CAPS, allows_q8=q8)
+ with mock.patch.object(P, "HELPER", _Helper()), \
+ mock.patch.object(P, "OUTPUT", tmp), \
+ mock.patch.object(P, "SYSTEM_CAPS", caps), \
+ mock.patch.object(P, "ltx_pack_preflight", lambda *a, **k: None), \
+ mock.patch.object(P, "hq_surface_missing", lambda *a, **k: []), \
+ mock.patch.object(P, "write_sidecar",
+ lambda _p, data: sidecars.append(data)):
+ P.run_job_inner({"id": "t", "params": params,
+ "started_ts": time.time()})
+ self.assertEqual(len(sent), 1)
+ return (sent[0]["action"], sent[0]["params"]["audio_conditioning_scale"],
+ sidecars[-1]["audio_conditioning_scale_used"])
+
+ def test_the_matrix(self):
+ cases = (
+ # (what the job carries, Q8 lane result, Q4 lane result)
+ (None, 3.0, 1.0), # new job, slider on Auto (field not sent)
+ ("1.0", 1.0, 1.0), # new job, slider dragged to 1.0 on purpose
+ ("2.5", 2.5, 2.5), # new job, explicit value
+ (1.0, 3.0, 1.0), # saved by 4.15.1: the old fabricated default
+ (2.2, 2.2, 2.2), # saved by 4.15.1 after a real drag
+ )
+ for acs, want_q8, want_q4 in cases:
+ with self.subTest(acs=acs, lane="q8"):
+ self.assertEqual(self._dispatch(acs, q8=True),
+ ("generate_a2v", want_q8, want_q8))
+ with self.subTest(acs=acs, lane="q4"):
+ self.assertEqual(self._dispatch(acs, q8=False),
+ ("generate_a2v_distilled", want_q4, want_q4))
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/webapp/index.html b/webapp/index.html
index 64d3ef4..37586b0 100644
--- a/webapp/index.html
+++ b/webapp/index.html
@@ -3371,12 +3371,17 @@ The last line"></textarea>
</div>
<div class="mf-cell" style="margin-top:8px">
<span class="mf-label">Audio conditioning strength</span>
+ <!-- Starts on AUTO and stays there until the thumb is dragged:
+ the two A2V pipelines read this number differently and only
+ the panel knows which one this Mac will run, so an untouched
+ control must send NOTHING rather than a number that means
+ "audio off" on one lane and "audio on" on the other. -->
<div class="range-strip">
- <input type="range" id="audioConditioningScale" min="0.5" max="5.0" step="0.1" value="1.0"
- oninput="document.getElementById('audioConditioningScaleVal').textContent=this.value">
- <span id="audioConditioningScaleVal" class="range-val">1.0</span>
+ <input type="range" id="audioConditioningScale" min="0.5" max="5.0" step="0.1" value="3.0"
+ data-auto="1" oninput="audioConditioningScaleChanged(this)">
+ <span id="audioConditioningScaleVal" class="range-val">Auto</span>
</div>
- <div class="hint" style="margin-top:2px">Higher = stronger audio adhesion, lower visual flexibility</div>
+ <div class="hint" style="margin-top:2px" id="audioConditioningScaleHint">Higher = stronger audio adhesion, lower visual flexibility</div>
</div>
</div>
</div>
diff --git a/webapp/js/characters.js b/webapp/js/characters.js
index a656715..f50ede4 100644
--- a/webapp/js/characters.js
+++ b/webapp/js/characters.js
@@ -223,6 +223,11 @@ function closeMusicInstallCard() {
function audioStudioInit() {
if (musicComposeActive()) setMainOutputsFilter('audio');
+ // Re-read every visit, not once: the tier is known by the time the pane is
+ // opened and the hint names a lane-specific number. A thumb the user has
+ // already dragged is left exactly where they put it.
+ const _acsEl = document.getElementById('audioConditioningScale');
+ if (!_acsEl || _acsEl.dataset.auto) audioConditioningScaleReset();
if (AUDIO_STUDIO.wired) return;
AUDIO_STUDIO.wired = true;
const audioSlot = document.getElementById('audioStudioAudioSlot');
@@ -424,6 +429,43 @@ async function audioStudioEnhancePrompt() {
finally { btn.disabled = false; btn.innerHTML = originalLabel; }
}
+// --- Audio conditioning strength: AUTO until the user says otherwise -------
+// The Q8 two-stage lane and the Q4 distilled lane read this number with
+// OPPOSITE meanings at 1.0 — on Q8 it lands on the guider's modality_scale,
+// whose term is (value - 1) * …, so 1.0 switches audio guidance off, while on
+// Q4 it multiplies the audio tokens and 1.0 is the identity. The panel picks
+// the lane at queue time (and can fall back from Q8 to Q4 when the Q8 files
+// are missing), so the browser must not guess: while the control is on Auto
+// the field is simply not sent and the panel fills in the lane's own default.
+function a2vLaneAudioScale() {
+ return (window.PHOSPHENE_CAP_TIER === 'q4') ? 1.0 : 3.0;
+}
+
+function audioConditioningScaleChanged(el) {
+ if (!el) return;
+ el.dataset.auto = '';
+ const out = document.getElementById('audioConditioningScaleVal');
+ if (out) out.textContent = el.value;
+}
+
+function audioConditioningScaleReset() {
+ const el = document.getElementById('audioConditioningScale');
+ if (!el) return;
+ el.dataset.auto = '1';
+ el.value = String(a2vLaneAudioScale());
+ const out = document.getElementById('audioConditioningScaleVal');
+ if (out) out.textContent = 'Auto';
+ const hint = document.getElementById('audioConditioningScaleHint');
+ if (hint) {
+ hint.textContent = 'Auto is ' + a2vLaneAudioScale().toFixed(1)
+ + ' on this Mac (' + (window.PHOSPHENE_CAP_TIER === 'q4' ? 'Q4' : 'Q8')
+ + ' pipeline) — the engine\'s own setting. Higher = stronger audio '
+ + 'adhesion, lower visual flexibility.'
+ + (window.PHOSPHENE_CAP_TIER === 'q4' ? ''
+ : ' On this lane 1.0 switches audio guidance off.');
+ }
+}
+
async function audioStudioGenerate() {
if (AUDIO_STUDIO.busy) return;
const status = document.getElementById('audioStudioStatus');
@@ -445,7 +487,11 @@ async function audioStudioGenerate() {
const dur = parseInt(document.getElementById('audioStudioDuration').value || '7', 10);
const frames = _a2vFramesForSeconds(dur);
const seed = parseInt(document.getElementById('audioStudioSeed').value || '-1', 10);
- const audioConditioningScale = parseFloat(document.getElementById('audioConditioningScale').value || '1.0');
+ // Auto = do not send the field at all; see audioConditioningScaleChanged.
+ const acsEl = document.getElementById('audioConditioningScale');
+ const audioConditioningScale = (acsEl && !acsEl.dataset.auto)
+ ? parseFloat(acsEl.value || String(a2vLaneAudioScale()))
+ : null;
// Offset into the source file. Clamped at 0 here as well as server-side —
// a negative start would be silently swallowed by load_audio.
const audioStartEl = document.getElementById('audioStudioStart');
@@ -469,7 +515,9 @@ async function audioStudioGenerate() {
fd.set('height', String(h));
fd.set('frames', String(frames));
fd.set('seed', String(seed));
- fd.set('audio_conditioning_scale', String(audioConditioningScale));
+ if (audioConditioningScale !== null && !Number.isNaN(audioConditioningScale)) {
+ fd.set('audio_conditioning_scale', String(audioConditioningScale));
+ }
fd.set('audio_start_time', String(audioStart));
fd.set('quality', 'high'); // A2V is always pipeline-class (Q8 dev or Q4 distilled)
// No accel, no enhance — A2V uses A2VidPipelineTwoStage's own walks.
@@ -3135,6 +3183,7 @@ Object.assign(globalThis, {
musicInstallRender, musicInstallStart, musicInstallStop,
windowPromptsInput,
audioStudioInit, audioStudioDurationChanged, audioStudioEnhancePrompt, audioStudioGenerate,
+ audioConditioningScaleChanged, audioConditioningScaleReset,
trainRecommendedPreset, trainUpdatePresetButtons, trainUpdatePresetNote, downloadSampleCharacter,
charactersInit, charactersRenderChips, charactersOpenCompose, charactersBackToGrid,
charactersHandleAudioUpload, charactersClearAudio, charactersUpdateStrengthDisplay, charactersSyncStrengthControls,