From b5d2f2f19b5a5256cf61b658448b4ece0cb77d55 Mon Sep 17 00:00:00 2001 From: Steve Calcott Date: Sun, 13 Sep 2026 16:05:29 +0000 Subject: [PATCH] Fix AuK editor failing on non-wav uploads (e.g. m4a) AuK's loader (librosa/soundfile) can't read compressed containers like m4a/mp3 at all - only demucs's loader handles those. Gradio keeps uploads in their original format, so any edit attempted directly on an uploaded m4a failed with "Format not recognised." Normalize to wav via ffmpeg at the single point a reference is set (use_as_reference), so both AuK and MOSS-TTS downstream always see wav regardless of what was uploaded. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01Y1oQ4h4WE4R9KRvMQLr5Ey --- webui/app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/webui/app.py b/webui/app.py index ff765ce..922a59d 100644 --- a/webui/app.py +++ b/webui/app.py @@ -78,6 +78,23 @@ def _run(cmd: list[str], cwd: Path, env: dict | None = None) -> None: raise gr.Error(f"Command failed ({cmd[0]}):\n{tail}") +def _ensure_wav(path: str) -> str: + """AuK's loader (librosa/soundfile) can't read compressed containers like + .m4a/.mp3 - only demucs's loader handles those. Normalize once, here, at + the point a reference is set, so everything downstream is always wav.""" + if Path(path).suffix.lower() == ".wav": + return path + out_path = WORKDIR / f"converted_{int(time.time() * 1000)}.wav" + result = subprocess.run( + ["ffmpeg", "-nostdin", "-y", "-i", path, "-ar", "44100", "-ac", "1", str(out_path)], + capture_output=True, text=True, timeout=120, + ) + if result.returncode != 0: + tail = "\n".join(result.stderr.strip().splitlines()[-15:]) + raise gr.Error(f"Could not convert '{path}' to wav:\n{tail}") + return str(out_path) + + def _ld_library_path_for_venv(venv_dir: Path) -> str: site_packages = next(venv_dir.glob(".venv/lib/python*/site-packages")) nvidia_dir = site_packages / "nvidia" @@ -123,6 +140,7 @@ def strip_vocals(input_audio: str): def use_as_reference(audio_path: str, history: list): if not audio_path: raise gr.Error("No audio to use yet.") + audio_path = _ensure_wav(audio_path) history = [audio_path] return audio_path, history, _history_label(history)