Spaces:
Running
Running
Commit History
-
fix(embedding): deterministic CLAP on full-length audio (random-truncation bug)β
laion-clap with enable_fusion=False randomly truncates any input longer than its ~10s window, so a whole-track embed returned a DIFFERENT vector every call (cos ~0.37-0.89 between repeats of the same 2:35 track). Anything built on whole-track vectors was measuring noise. Reproduced: 40s file, 3 embeds β cos 0.91/0.74/0.89; after fix β 1.00000/1.00000/1.00000. - clap_worker._embed: tile audio into fixed consecutive 10s windows (each <= the CLAP window, so none is truncated β each deterministic), embed every tile, mean, L2-normalize. Deterministic in β deterministic out, and the vector describes the whole track not a random tenth. - clap_worker._load_model: model.eval() (disable dropout) as belt-and-suspenders. - clap_worker._selftest: add a repeat-embed guard on a >window (30s) time- varying probe β asserts repeat cos >= 0.999, so a truncation regression fails the run instead of silently shipping noise. The old collapse check uses 5s probes (sub-window) and was blind to thiβ¦2c07fe1
-
feat(embedding): expose CLAP similarity vector on the API as a stream-safe subprocess islandβ
Issues 1+2 from the pipeline handoff: no path could return an embedding. - clap_worker.py (new): loads CLAP in a short-lived subprocess (same island pattern as demucs/basic-pitch), so torch + the checkpoint are never resident next to an SA3 gen. Embeds one file, writes an L2-normalized .npy, exits. Mandatory load-time sanity self-test (sine/noise/silence must land far apart) refuses to write a collapsed/poisoned vector. - pipeline._stage_embedding: rewritten to shell out to the worker; drops the in-process CLAP load and the embedding-only re-decode. Fixes a latent stub bug β amodel was hard-coded HTSAT-base (music ckpt arch) but the default download is HTSAT-tiny; worker now auto-matches arch to checkpoint. - app.audio_to_prompt_api: new `embedding` param (appended last, positional- compatible), run_embedding=bool(embedding), returns `embedding` (512-float L2-normalized list) + `embedding_dim`; hidden checkbox input registered. - requirements.txt: uncomment laion-claβ¦ede2251
-
docs+copy: genre/mood/instrument are measured now, not LLM-inferredβ
Update the ingest note + analysis cheat sheet to reflect the essentia stage β the 'vibe is guessed, can miss' caveat no longer holds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>827dc95
-
docs(api): flag LLM-path latency β use submit() not predict()β
The llm=true path makes two Pollinations calls (~40s) and trips gradio_client's synchronous predict() read timeout. Document the submit()/poll pattern + the single-call collapse option. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>8bb2e2e -
feat(api): llm flag on audio_to_prompt β Pollinations-polished promptβ
- llm=true runs analyse -> write_brief -> write_sa3_prompt_upload_lens, returning a natural-language SA3 prompt (the flow: audio -> analyse -> LLM -> prompt). lens param picks match/loose/free - Space pays: narrative calls with api_key='' fall through to the POLLINATIONS_API_KEY Space secret (wallet.get_key resolution order) - never fails because of the LLM: any LLMError (no key / 402 / timeout) degrades to the deterministic prompt, with the reason in prompt_source - adds prompt_source + brief to the response; deterministic path unchanged - docs/API.md: llm/lens params, two-mode explainer, POLLINATIONS_API_KEY setup Verified locally: llm=true returns llm:<model> + brief + polished prompt; forced 402 falls back to deterministic cleanly; bad lens normalizes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>5321105 -
feat(api): headless audio_to_prompt endpoint β audio in, SA3 prompt outβ
- new api_name="audio_to_prompt" route (hidden components + button, the proven gradio_client pattern): file in -> deterministic SA3 prompt + measured JSON out. No wallet, no LLM, no pollen β structural prompt from outputs.sa3_variation_prompt - fast=True skips demucs + basic-pitch (~2s vs ~30s); reuses analyze()'s run_stems/run_midi flags - same ingest as the UI upload: video containers + aac-family are ffmpeg-extracted via _prepare_source_audio - gated by Space secret AUDIO_BRIEF_API_TOKEN (constant-time compare); open when unset - returns {prompt, match_style_prompt, measured{...}, fast_mode, stages_ok, errors} - docs/API.md with gradio_client usage + gating setup Verified locally end-to-end via gradio_client.handle_file: fast + full (4-stem demucs) paths, token accept/reject, video extract, missing-file error. Endpoint appears in view_api. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>c8b024e
-
docs: analysis cheat sheet β what measures what, what's LLM-inferredβ
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>109ee6a
-
refactor(transform): URL-pass pattern β bridge fetches source, not browserβ
Codex revision of Phase 2 wiring. The earlier bytes-courier flow had the browser fetch the source from Gradio's file proxy, base64-encode, and POST 4MB of inflated JSON to the bridge. That forced the SA3 source preview to be a raw <audio> tag (so JS could read .src) β which killed the wavesurfer waveform Morpho still got to use. Now: the browser POSTs an AUDIO_URL β the relative /gradio_api/file=β¦ path resolved against the page origin (the .hf.space subdomain). The bridge β which has internet but cannot reach localhost β fetches the URL itself. Same Python-talks-to-engine mental model Morpho already uses; HF Python still can't reach the bridge, so the browser stays the request initiator. The bytes never base64-roundtrip across two JSON hops. app.py: β’ sa3_source_audio reverts to gr.Audio (wavesurfer waveform restored). β’ sa3_source_url Textbox (hidden) holds the relative file-proxy path. β’ _sa3_pick_tile writes path to both: gr.Audio for visual, Textbox for the JS prelude. β¦7a57c31 -
feat(local-bridge): POST /transform β SA3 audio-to-audio via init-audioβ
Adds a second endpoint to the local-gen bridge so the upcoming TRANSFORM-tab Local-SA3 engine can do audio-to-audio without breaking the existing /generate flow. Request shape (JSON, parallel to /generate so the browser JS reuses the same fetch pattern): POST /transform { prompt, audio_b64, duration, init_strength, steps, cfg, negative_prompt } Returns: audio/wav Implementation: - audio_b64 is base64-decoded server-side and re-encoded via ffmpeg to SA3's required WAV format (44.1 kHz / 16-bit PCM, stereo). Any source format ffmpeg can read works β mp3 from Pollinations, wav from the existing /generate path, m4a uploads, etc. - shells out to ~/sa3_mlx/sa3 with --init-audio + --init-noise-level (= init_strength clamped to [0.01, 1.0]). CLI verified via ~/sa3_mlx/sa3 --help; see memory note local-sa3-mlx.md for the full flag matrix. - CFG and --negative-prompt only added to argv when cfg != 1.0 (SA3 skips the uncond branch otherwise, so the flags would be wasteβ¦160614f
-
Bridge: widen Access-Control-Allow-Headers to 'Content-Type, content-type'β
Per Codex defensive recommendation. CORS header matching is case-insensitive per the Fetch spec, but some browser builds / extensions have been observed comparing case-sensitively. Cheap to widen the allowlist. Belt-and-braces β PNA preflight already verified passing. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>8a9a9dd -
Local bridge: handle Chrome PNA preflight; drop bad mixed-content guardβ
The TypeError: Failed to fetch was Chrome's Private Network Access (PNA) enforcement, not mixed content. PNA fires a CORS-style preflight on cross-origin HTTPS-public β private-network-IP requests with header Access-Control-Request-Private-Network: true. The server must respond Access-Control-Allow-Private-Network: true or the browser refuses the real request β even though Chrome explicitly EXEMPTS http://localhost from mixed-content blocking. Two changes: - docs/local-gen-server-example.py: Drop FastAPI's CORSMiddleware (doesn't add PNA-Allow). Replace with one explicit middleware that emits CORS + Access-Control-Allow-Private-Network on every response and answers OPTIONS preflights as 204 directly (no SA3 spin-up on a preflight). Codex's pattern verbatim. - app.py: Remove the bad mixed-content guard added in 32982d5 β it incorrectly blocked the very fetch Chrome would have allowed. Localhost is exempt from mixed-content in Chromeβ¦5da7b89 -
Local SA3 bridge: wire run_mlx_sa3 to ~/sa3_mlx/sa3 with verified CLIβ
The example file's run_mlx_sa3 was a stub with placeholder flags. Replaced with the real CLI from engine/audio-providers.js:302 β the same one the pj-battle engine uses to drive the install at ~/sa3_mlx/sa3: --prompt <text> --dit sm-music --decoder same-s --seconds N --out path Output is WAV; default DIT is sm-music (fits 8GB RAM). Spawn-per- request only β never two SA3 processes concurrent (each holds ~2 GB).f3537fe
-
Initial deploy
3cc5b15