From cb66dcb8e3caeee14e0787a8ef439303e5cbbdb6 Mon Sep 17 00:00:00 2001 From: GAJ3T Date: Mon, 26 Oct 2026 05:16:59 -0400 Subject: [PATCH] Copying More Repo to Demo --- AceStepXL-Training/.gitignore | 5 + AceStepXL-Training/README.md | 225 +++++++ AceStepXL-Training/Start-VoiceStudio.ps1 | 29 + AceStepXL-Training/requirements.txt | 6 + .../src/voice_studio/__init__.py | 1 + .../src/voice_studio/ace_worker.py | 47 ++ AceStepXL-Training/src/voice_studio/server.py | 299 ++++++++++ .../src/voice_studio/static/app.js | 500 ++++++++++++++++ .../src/voice_studio/static/index.html | 139 +++++ .../src/voice_studio/static/styles.css | 254 ++++++++ AceStepXL-Training/src/voice_studio/studio.py | 549 ++++++++++++++++++ 11 files changed, 2054 insertions(+) create mode 100644 AceStepXL-Training/.gitignore create mode 100644 AceStepXL-Training/README.md create mode 100644 AceStepXL-Training/Start-VoiceStudio.ps1 create mode 100644 AceStepXL-Training/requirements.txt create mode 100644 AceStepXL-Training/src/voice_studio/__init__.py create mode 100644 AceStepXL-Training/src/voice_studio/ace_worker.py create mode 100644 AceStepXL-Training/src/voice_studio/server.py create mode 100644 AceStepXL-Training/src/voice_studio/static/app.js create mode 100644 AceStepXL-Training/src/voice_studio/static/index.html create mode 100644 AceStepXL-Training/src/voice_studio/static/styles.css create mode 100644 AceStepXL-Training/src/voice_studio/studio.py diff --git a/AceStepXL-Training/.gitignore b/AceStepXL-Training/.gitignore new file mode 100644 index 0000000..fc25436 --- /dev/null +++ b/AceStepXL-Training/.gitignore @@ -0,0 +1,5 @@ +workspace/ +__pycache__/ +*.py[cod] +.venv/ +.env diff --git a/AceStepXL-Training/README.md b/AceStepXL-Training/README.md new file mode 100644 index 0000000..8da4801 --- /dev/null +++ b/AceStepXL-Training/README.md @@ -0,0 +1,225 @@ +# Voice Studio + +A local, browser-based voice-character training workbench for ACE-Step 1.5 XL. +Maintain any number of characters, each with separate recordings, annotations, +dataset versions, jobs, logs, and exports. + +## Delivery status + +Source implementation only. At the user's request, the application has **not** +been launched or tested, dependencies have not been installed, and no models +have been trained. No services or containers have been started. + +The default paths reflect the existing local installation inspected during +development. Header inspection found six stereo, 48 kHz PCM-16 WAV recordings +in the initial character folder, totaling approximately 17 minutes. The audio +has not been listened to or assessed for vocal quality or training permission. + +## Start when ready + +From this project directory in PowerShell: + +```powershell +.\Start-VoiceStudio.ps1 +``` + +Open . The launcher does not install packages or open +another ACE-Step instance. It uses: + +- ACE-Step installation: `D:\ai\ACE-Step-1.5` +- Python: `D:\ai\ACE-Step-1.5\.venv\Scripts\python.exe` +- Character library: `..\Voice Characters` +- Generated data: `.\workspace` + +To supply another interpreter or installation: + +```powershell +.\Start-VoiceStudio.ps1 -AceStepRoot "D:\Tools\ACE-Step-1.5" ` + -Python "D:\Tools\ACE-Step-1.5\.venv\Scripts\python.exe" -Port 9874 +``` + +The browser server requires Python 3.10+ and the small set of packages in +`requirements.txt`. It does not install the ACE-Step runtime. If those +packages are missing, install them deliberately into the chosen interpreter: + +```powershell +& "D:\ai\ACE-Step-1.5\.venv\Scripts\python.exe" -m pip install -r .\requirements.txt +``` + +Review changes to a shared environment before installing. ACE-Step itself +must have its own CUDA-enabled Torch, training dependencies, and downloaded +model assets. Training requires an NVIDIA CUDA GPU; memory requirements +depend on the XL variant, clip duration, and upstream implementation. + +No Docker, Postman, cloud services, paid APIs, or MCP server is required. +This is a local web application, not an MCP integration. The browser server +binds only to `127.0.0.1`; do not expose it through a public proxy. + +## Multiple voice characters + +Every immediate subfolder of the character library is a separate character. +The existing `GothMetalMaleV2` folder is discovered, not hard-coded. + +Use **New character** to create another folder and independent workspace, +then **Add recordings** to copy WAV, FLAC, or OGG files into it. Uploads receive +unique filenames; existing files are never overwritten. Alternatively, add +a character subfolder and audio files directly to the library before opening +or refreshing the studio. + +Display names, generation triggers, default captions, and language are +editable. Use a distinct trigger per voice. Identity changes apply to future +datasets and do not silently rewrite old annotations. + +Environment overrides: + +| Variable | Meaning | +|---|---| +| `ACESTEP_ROOT` | Default ACE-Step installation | +| `VOICE_STUDIO_SOURCE` | Default recording library | +| `VOICE_STUDIO_WORKSPACE` | Generated datasets, settings, job history, and exports | + +Saved settings override the default installation and source paths. +The output workspace is selected before launch, not moved through the UI. + +## Dataset preparation and review + +1. Select or create a character. +2. Add **isolated vocals** that you own or are authorized to use. +3. Set the clip duration and silence threshold, then prepare a dataset. +4. Listen to the resulting clips. Correct captions and enter accurate lyrics, + syllables, or descriptions of the actual non-lexical vocalisation. +5. Mark each clip reviewed and save. + +Preparation creates a new version every time: + +```text +workspace\ + \ + character.json + datasets\ + \ + ace_audio\ 48 kHz stereo PCM-16 WAV + svc_audio\ 40 kHz mono PCM-16 WAV + dataset.json Native ACE-Step samples/metadata + segments.json Original paths and segment timestamps + tensors\ Generated only by explicit preprocessing + ready.json Written only after complete preprocessing + jobs\ + \ + job.json + output.log + recipe.json Training jobs only + adapter\ Training outputs, if produced by the backend +``` + +Silence detection uses 20 ms energy windows, brief boundary padding, and a +minimum retained segment length of 1.5 seconds. Long spans are cut near a +low-energy boundary where possible; audition cuts because this is not a +phoneme-aware segmenter. Quiet clips below the configured threshold are +excluded and reported. Very short isolated sounds may be omitted. + +Audio is not denoised, separated, pitch-corrected, or transcribed automatically. +Resampling peaks are limited only when needed to prevent output clipping. +For SVC, a phase-cancelling stereo downmix falls back to the strongest channel +and produces a warning. Original recordings are never modified. + +Unknown lyrics remain blank. Vocal data is explicitly **not** marked +instrumental. ACE-Step preprocessing is blocked until every clip has vocal +text, a caption, and a listening-review confirmation. This does not guarantee +that an annotation is correct; it is a human review gate. + +## Path A: new songs with ACE-Step XL + +1. Open **Train a voice**. +2. Select the exact installed XL variant: XL-SFT, XL-Turbo, or XL-Base. +3. Confirm permission and suitable vocal data. +4. Run **Preprocess clips**. The studio invokes upstream's two-pass + `preprocess_audio_files` in a separate process using the ACE-Step interpreter. +5. Run **Start training** after preprocessing completes. + +The integration targets the local ACE-Step source interfaces inspected at +commit `14c0211`: + +- `acestep.training_v2.preprocess.preprocess_audio_files` +- `train.py --plain --yes fixed` + +Commands use the literal checkpoint directory name plus an explicit +`--base-model xl_*`. This avoids the inspected CLI path validator's missing +XL aliases while retaining the correct XL family for training configuration. +No upstream files are modified. + +Starting settings: batch size 1, BF16, rank 16, learning rate 0.0001, +gradient accumulation 4, gradient checkpointing, encoder offload, AdamW, +and zero DataLoader workers. These are starting settings, not a validated +24 GB memory guarantee. Default 12-second clips reduce activation memory. +Close other GPU workloads before training. Lower clip length/rank if needed. + +Every preprocessing attempt gets a separate tensor directory. Completion +requires all expected samples to succeed. A dataset hash and XL variant are +recorded; changes invalidate readiness and require preprocessing again. + +The console displays actual subprocess output, not estimated loss curves or +invented progress. Nonzero exits and explicit backend `[FAIL]` reports are +failures. Training completion additionally requires final `.safetensors` +weights and their adapter configuration. That check does **not** certify voice +quality: audition checkpoints with prompts and melodies not used in training. + +Load the resulting adapter **directory**, retaining `adapter_config.json` and +its weights together, through the matching ACE-Step XL model's adapter loader. +Include the trigger recorded in that training job's `recipe.json` in the +generation caption; renaming a character does not rewrite an old model's +trigger. In ComfyUI, the +installed nodes must explicitly support the XL variant and the saved adapter +format; compatibility is not assumed and weights are not silently converted. + +Syllable runs can provide timbre and pitch coverage, but do not establish good +lyric pronunciation or full-song generalisation. A voice-only set can also +bias outputs toward a cappella performances. Add authorized clean sung phrases +with varied pitches, vowels, consonants, dynamics, and accurately annotated +lyrics; evaluate on held-out performances before relying on the character. + +## Path B: singing voice conversion + +For preserving an existing singer's melody, timing, and performance while +changing the voice, use a **separate RVC model**, for example through +[Applio](https://github.com/IAHispano/Applio). + +1. Prepare and listen to the character's vocal clips. +2. Open **Models & exports** and build an SVC dataset export. +3. Download and extract the ZIP. It contains the mono 40 kHz WAVs and local + training handoff instructions, not a trained conversion model. +4. In a separately installed Applio environment, select a unique model name + and the extracted character folder; use 40 kHz, preprocess, extract + pitch/features, train, and build its retrieval index following the current + Applio training guide. +5. Use its `.pth` and `.index` for conversion of isolated source vocals, then + mix the converted vocals back with the instrumental. + +Applio installation, downloads, training, and conversion are **not automated** +by this studio. That boundary avoids guessing an unselected backend version +or mixing conflicting Torch dependencies. SVC training generally does not +need lyrics, so the export is available without ACE-Step lyric annotation. +It still requires human listening and authorized audio. + +An ACE-Step LoRA is not an RVC/so-vits-svc model. Renaming an adapter does not +convert it. ACE-Step audio conditioning/cover workflows may be useful, but +are not a guaranteed drop-in replacement for performance-preserving SVC. + +## Job and file behaviour + +- One dataset/GPU/export job runs at a time. Mutations are blocked during jobs. +- History, logs, and artifacts persist per character. Interrupted jobs are + marked failed on the next studio startup, never reported as completed. +- Stopping the studio requests termination of its active backend process. + There is no browser cancellation/resume UI. A subsequent training request + starts a new run; native CLI resume remains an upstream advanced workflow. +- Preparation and uploads write only new files. Earlier datasets and partial + failed runs are retained for inspection; no automatic deletion is performed. +- Model weights and audio remain local. The application contains no telemetry, + remote fonts, external JavaScript, or audio-upload services. + +### Upstream references + +- [ACE-Step 1.5](https://github.com/ace-step/ACE-Step-1.5) +- [ACE-Step LoRA training tutorial](https://github.com/ace-step/ACE-Step-1.5/blob/main/docs/en/LoRA_Training_Tutorial.md) +- [Applio](https://github.com/IAHispano/Applio) diff --git a/AceStepXL-Training/Start-VoiceStudio.ps1 b/AceStepXL-Training/Start-VoiceStudio.ps1 new file mode 100644 index 0000000..b013fd0 --- /dev/null +++ b/AceStepXL-Training/Start-VoiceStudio.ps1 @@ -0,0 +1,29 @@ +param( + [string]$AceStepRoot = "D:\ai\ACE-Step-1.5", + [string]$Python = "", + [ValidateRange(1024, 65535)] + [int]$Port = 9874 +) + +$ErrorActionPreference = "Stop" +if ($env:ACESTEP_ROOT -and -not $PSBoundParameters.ContainsKey("AceStepRoot")) { + $AceStepRoot = $env:ACESTEP_ROOT +} +if (-not $Python) { $Python = Join-Path $AceStepRoot ".venv\Scripts\python.exe" } +if (-not (Test-Path -LiteralPath $Python -PathType Leaf)) { + throw "Python not found: $Python. Supply -Python with a prepared Python interpreter." +} + +$env:ACESTEP_ROOT = $AceStepRoot +$env:PYTHONPATH = Join-Path $PSScriptRoot "src" +if (-not $env:VOICE_STUDIO_SOURCE) { + $env:VOICE_STUDIO_SOURCE = Join-Path (Split-Path $PSScriptRoot -Parent) "Voice Characters" +} +Write-Host "" +Write-Host "VOICE STUDIO" -ForegroundColor Magenta +Write-Host "Open http://127.0.0.1:$Port in your browser." +Write-Host "Training starts only when you explicitly request it in the studio." +Write-Host "Press Ctrl+C to stop the studio." +Write-Host "" +& $Python -m voice_studio.server --port $Port +exit $LASTEXITCODE diff --git a/AceStepXL-Training/requirements.txt b/AceStepXL-Training/requirements.txt new file mode 100644 index 0000000..2ca4cc9 --- /dev/null +++ b/AceStepXL-Training/requirements.txt @@ -0,0 +1,6 @@ +fastapi>=0.115,<1 +uvicorn>=0.30,<1 +python-multipart>=0.0.18,<1 +numpy>=1.26,<3 +scipy>=1.12,<2 +soundfile>=0.12,<1 diff --git a/AceStepXL-Training/src/voice_studio/__init__.py b/AceStepXL-Training/src/voice_studio/__init__.py new file mode 100644 index 0000000..ed2fbb7 --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/__init__.py @@ -0,0 +1 @@ +"""Local voice-character dataset and training studio.""" diff --git a/AceStepXL-Training/src/voice_studio/ace_worker.py b/AceStepXL-Training/src/voice_studio/ace_worker.py new file mode 100644 index 0000000..535c322 --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/ace_worker.py @@ -0,0 +1,47 @@ +"""Isolate GPU-heavy upstream preprocessing from the browser server.""" + +from __future__ import annotations + +import argparse +import json +import logging +import sys +from pathlib import Path + + +def main() -> None: + parser = argparse.ArgumentParser() + parser.add_argument("--ace-root", type=Path, required=True) + parser.add_argument("--dataset", type=Path, required=True) + parser.add_argument("--output", type=Path, required=True) + parser.add_argument("--model", required=True) + args = parser.parse_args() + logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s") + sys.path.insert(0, str(args.ace_root.resolve())) + from acestep.training_v2.preprocess import preprocess_audio_files + + data = json.loads(args.dataset.read_text(encoding="utf-8")) + expected = len(data["samples"]) + if not expected: + raise ValueError("The dataset is empty.") + for sample in data["samples"]: + if not sample.get("reviewed") or not sample.get("lyrics", "").strip(): + raise ValueError(f"Clip requires reviewed lyrics: {sample['filename']}") + if not Path(sample["audio_path"]).is_file(): + raise FileNotFoundError(sample["audio_path"]) + result = preprocess_audio_files( + audio_dir=None, output_dir=str(args.output), + checkpoint_dir=str(args.ace_root / "checkpoints"), variant=args.model, + max_duration=max(sample["duration"] for sample in data["samples"]) + 1, + dataset_json=str(args.dataset), device="cuda", precision="bf16", + progress_callback=lambda current, total, message: print( + f"[{current}/{total}] {message}", flush=True + ), + ) + if result["failed"] or result["processed"] != expected or result["total"] != expected: + raise RuntimeError(f"Incomplete preprocessing: expected {expected}, received {result}") + print(json.dumps(result), flush=True) + + +if __name__ == "__main__": + main() diff --git a/AceStepXL-Training/src/voice_studio/server.py b/AceStepXL-Training/src/voice_studio/server.py new file mode 100644 index 0000000..ee64fc4 --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/server.py @@ -0,0 +1,299 @@ +from __future__ import annotations + +import argparse +import os +import subprocess +import uuid +from contextlib import asynccontextmanager +from pathlib import Path +from typing import Literal +from urllib.parse import urlsplit + +import soundfile as sf +from fastapi import FastAPI, File, HTTPException, Request, UploadFile +from fastapi.responses import FileResponse, JSONResponse +from fastapi.staticfiles import StaticFiles +from pydantic import BaseModel, Field + +from .studio import ( + MODELS, WORKSPACE, character, characters, create_character, dataset_path, dataset_view, + jobs, read_json, save_character, settings, slug, training_command, write_json, +) + +STATIC = Path(__file__).with_name("static") + + +@asynccontextmanager +async def lifespan(app: FastAPI): + WORKSPACE.mkdir(parents=True, exist_ok=True) + jobs.load_history() + yield + jobs.shutdown() + + +app = FastAPI(title="Voice Studio", docs_url=None, redoc_url=None, lifespan=lifespan) + + +@app.middleware("http") +async def local_only(request: Request, call_next): + host = urlsplit("//" + request.headers.get("host", "")).hostname + origin = request.headers.get("origin") + if host not in {"localhost", "127.0.0.1", "::1"}: + return JSONResponse({"detail": "Voice Studio accepts local connections only."}, status_code=403) + if origin and origin != f"{request.url.scheme}://{request.headers.get('host')}": + return JSONResponse({"detail": "Cross-origin requests are not allowed."}, status_code=403) + response = await call_next(request) + response.headers["X-Content-Type-Options"] = "nosniff" + response.headers["Referrer-Policy"] = "no-referrer" + response.headers["Cache-Control"] = "no-store" + return response + + +@app.exception_handler(ValueError) +async def value_error(request: Request, exc: ValueError): + return JSONResponse({"detail": str(exc)}, status_code=400) + + +@app.exception_handler(OSError) +async def io_error(request: Request, exc: OSError): + return JSONResponse({"detail": str(exc)}, status_code=404 if isinstance(exc, FileNotFoundError) else 400) + + +class CharacterInput(BaseModel): + name: str = Field(min_length=1, max_length=80) + trigger: str = Field(default="", max_length=64) + + +class ProfileInput(BaseModel): + name: str = Field(min_length=1, max_length=80) + trigger: str = Field(min_length=1, max_length=64) + caption: str = Field(min_length=1, max_length=2000) + language: str = Field(min_length=1, max_length=32) + + +class SettingsInput(BaseModel): + ace_root: str = Field(min_length=1) + ace_python: str = Field(min_length=1) + source_root: str = Field(min_length=1) + + +class AnnotationInput(BaseModel): + dataset_version: str = Field(min_length=1, max_length=80) + caption: str = Field(min_length=1, max_length=4000) + lyrics: str = Field(default="", max_length=10000) + reviewed: bool = False + + +class JobInput(BaseModel): + action: Literal["prepare", "preprocess", "train", "export_svc"] + model: Literal[ + "acestep-v15-xl-sft", "acestep-v15-xl-turbo", "acestep-v15-xl-base" + ] = "acestep-v15-xl-sft" + clip_seconds: float = Field(default=12, ge=3, le=30) + silence_db: float = Field(default=-45, ge=-70, le=-20) + epochs: int = Field(default=100, ge=1, le=2000) + rank: Literal[8, 16, 32, 64] = 16 + learning_rate: float = Field(default=0.0001, ge=0.000001, le=0.001) + accumulation: int = Field(default=4, ge=1, le=32) + authorized: bool = False + + +def model_status(config: dict) -> list[dict]: + return [ + {"id": model, "label": model.replace("acestep-v15-", "").upper().replace("-", " "), + "available": (Path(config["ace_root"]) / "checkpoints" / model / "config.json").is_file()} + for model in MODELS + ] + + +def artifacts(cid: str) -> list[dict]: + base = WORKSPACE / cid + result = [] + if not base.is_dir(): + return result + for path in base.rglob("*"): + if not path.is_file(): + continue + if path.suffix not in {".zip", ".safetensors"} and path.name not in { + "adapter_config.json", "recipe.json", "dataset.json", "segments.json", "output.log", + }: + continue + result.append({ + "name": path.name, "relative": str(path.relative_to(WORKSPACE)).replace(os.sep, "/"), + "bytes": path.stat().st_size, "modified": path.stat().st_mtime, + }) + return sorted(result, key=lambda item: item["modified"], reverse=True) + + +@app.get("/api/bootstrap") +def bootstrap(): + config = settings() + return { + "settings": config, "characters": characters(), "models": model_status(config), + "jobs": jobs.snapshot(), "busy": jobs.busy, + "backend_available": Path(config["ace_python"]).is_file() + and (Path(config["ace_root"]) / "train.py").is_file(), + "source_available": Path(config["source_root"]).is_dir(), + } + + +@app.post("/api/characters", status_code=201) +def add_character(body: CharacterInput): + with jobs.lock: + jobs.ensure_idle() + return create_character(body.name, body.trigger) + + +@app.get("/api/characters/{cid}") +def get_character(cid: str): + item = character(cid) + return {**item, "prepared": dataset_view(item), "artifacts": artifacts(cid)} + + +@app.put("/api/characters/{cid}") +def update_character(cid: str, body: ProfileInput): + with jobs.lock: + jobs.ensure_idle() + item = character(cid) + item.update(body.model_dump()) + item["trigger"] = slug(body.trigger) + save_character(item) + return item + + +@app.post("/api/characters/{cid}/recordings") +def upload_recordings(cid: str, files: list[UploadFile] = File(...)): + with jobs.lock: + jobs.ensure_idle() + item = character(cid) + accepted = [] + for upload in files: + filename = (upload.filename or "").replace("\\", "/").rsplit("/", 1)[-1] + suffix = Path(filename).suffix.lower() + if suffix not in {".wav", ".flac", ".ogg"}: + raise ValueError("Supported recordings: WAV, FLAC, OGG. Earlier files in this batch may have been saved.") + target = Path(item["source"]) / f"{slug(Path(filename).stem)}-{uuid.uuid4().hex[:8]}{suffix}" + temporary = target.with_suffix(suffix + ".upload") + try: + size = 0 + with temporary.open("xb") as handle: + while chunk := upload.file.read(1024 * 1024): + size += len(chunk) + if size > 512 * 1024 * 1024: + raise ValueError("Each recording must be under 512 MiB. Earlier uploads remain saved.") + handle.write(chunk) + try: + info = sf.info(str(temporary)) + except (RuntimeError, sf.LibsndfileError) as exc: + raise ValueError(f"{filename}: unsupported or damaged audio: {exc}") from exc + if not info.frames or info.channels not in {1, 2}: + raise ValueError(f"{filename}: expected nonempty mono/stereo audio.") + temporary.replace(target) + accepted.append(target.name) + finally: + temporary.unlink(missing_ok=True) + upload.file.close() + return {"saved": accepted} + + +@app.get("/api/characters/{cid}/recordings/{rid}") +def recording_audio(cid: str, rid: str): + for recording in character(cid)["recordings"]: + if recording["id"] == rid: + return FileResponse(recording["path"]) + raise HTTPException(404, "Recording not found.") + + +@app.get("/api/characters/{cid}/samples/{sid}/audio") +def sample_audio(cid: str, sid: str): + data = read_json(dataset_path(character(cid))) + for sample in data["samples"]: + if sample["id"] == sid: + path = Path(sample["audio_path"]).resolve() + if not path.is_relative_to(WORKSPACE / cid): + raise ValueError("Audio path is outside this character's workspace.") + return FileResponse(path, media_type="audio/wav") + raise HTTPException(404, "Clip not found.") + + +@app.put("/api/characters/{cid}/samples/{sid}") +def update_sample(cid: str, sid: str, body: AnnotationInput): + with jobs.lock: + jobs.ensure_idle() + path = dataset_path(character(cid)) + if path.parent.name != body.dataset_version: + raise ValueError("The active dataset changed. Refresh the page before annotating its clips.") + data = read_json(path) + for sample in data["samples"]: + if sample["id"] == sid: + if body.reviewed and not body.lyrics.strip(): + raise ValueError("Enter accurate lyrics or a description of the actual wordless vocalisation.") + sample.update(body.model_dump(exclude={"dataset_version"})) + sample.update(raw_lyrics=body.lyrics, labeled=body.reviewed, is_instrumental=False) + write_json(path, data) + return sample + raise HTTPException(404, "Clip not found.") + + +@app.post("/api/characters/{cid}/jobs", status_code=202) +def start_job(cid: str, body: JobInput): + return jobs.start(cid, body.action, body.model_dump()) + + +@app.get("/api/jobs") +def get_jobs(): + return {"jobs": jobs.snapshot(), "busy": jobs.busy} + + +@app.post("/api/characters/{cid}/recipe") +def preview_recipe(cid: str, body: JobInput): + item = character(cid) + prepared = dataset_view(item) + tensors = (Path(prepared["ready"]["tensor_dir"]) if prepared.get("ready") + else WORKSPACE / cid / "pending-tensors") + command = training_command(item, body.model_dump(), tensors, WORKSPACE / cid / "next-run" / "adapter") + return {"command": subprocess.list2cmdline(command), "args": command, "executed": False} + + +@app.put("/api/settings") +def update_settings(body: SettingsInput): + with jobs.lock: + jobs.ensure_idle() + config = body.model_dump() + if any(not Path(value).is_absolute() for value in config.values()): + raise ValueError("Use absolute local paths for all settings.") + if not Path(config["source_root"]).is_dir(): + raise ValueError("The recording library folder must already exist.") + write_json(WORKSPACE / "settings.json", config) + return settings() + + +@app.get("/api/download/{relative:path}") +def download(relative: str): + path = (WORKSPACE / relative).resolve() + if not path.is_relative_to(WORKSPACE) or not path.is_file(): + raise HTTPException(404, "Artifact not found.") + if path.suffix not in {".zip", ".safetensors", ".json", ".log"}: + raise HTTPException(400, "This file type is not available as an artifact.") + return FileResponse(path, filename=path.name) + + +@app.get("/") +def home(): + return FileResponse(STATIC / "index.html") + + +app.mount("/static", StaticFiles(directory=str(STATIC)), name="static") + + +def main() -> None: + import uvicorn + + parser = argparse.ArgumentParser(description="Voice Studio - local browser training workbench") + parser.add_argument("--port", type=int, default=9874) + args = parser.parse_args() + uvicorn.run(app, host="127.0.0.1", port=args.port, log_level="info") + + +if __name__ == "__main__": + main() diff --git a/AceStepXL-Training/src/voice_studio/static/app.js b/AceStepXL-Training/src/voice_studio/static/app.js new file mode 100644 index 0000000..5364ae7 --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/static/app.js @@ -0,0 +1,500 @@ +"use strict"; + +const $ = (selector) => document.querySelector(selector); +const state = { + characters: [], character: null, cid: null, sample: null, jobs: [], busy: false, + bootstrap: null, jobId: null, dirty: false, polling: false, toastTimer: null, +}; +const pages = new Set(["overview", "recordings", "training", "exports", "settings"]); +const labels = { + prepare: "Dataset preparation", preprocess: "XL preprocessing", + train: "XL adapter training", export_svc: "SVC dataset export", +}; +const escapeHTML = (value) => String(value ?? "").replace(/[&<>"']/g, (c) => ({ + "&": "&", "<": "<", ">": ">", '"': """, "'": "'", +}[c])); +const icon = (name) => ``; +const initials = (name) => name.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[\s_-]+/) + .filter(Boolean).map((part) => part[0]).slice(0, 2).join("").toUpperCase() || "VC"; +const duration = (seconds) => { + const total = Math.max(0, Math.round(Number(seconds) || 0)); + return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, "0")}`; +}; +const size = (bytes) => bytes >= 1024 ** 3 ? `${(bytes / 1024 ** 3).toFixed(1)} GB` + : bytes >= 1024 ** 2 ? `${(bytes / 1024 ** 2).toFixed(1)} MB` + : `${Math.max(1, Math.round(bytes / 1024))} KB`; +const empty = (text) => `
${escapeHTML(text)}
`; +const downloadURL = (relative) => "/api/download/" + relative.split(/[\\/]/).map(encodeURIComponent).join("/"); + +async function api(path, options = {}) { + const init = { ...options }; + if (init.body && !(init.body instanceof FormData)) { + init.headers = { "Content-Type": "application/json", ...init.headers }; + init.body = JSON.stringify(init.body); + } + const response = await fetch("/api" + path, init); + const type = response.headers.get("content-type") || ""; + if (!type.includes("application/json")) throw new Error(`Unexpected server response (${response.status}).`); + const result = await response.json(); + if (!response.ok) { + const detail = Array.isArray(result.detail) + ? result.detail.map((item) => `${item.loc?.join(".") || "Input"}: ${item.msg}`).join("; ") + : result.detail; + throw new Error(detail || `Request failed (${response.status}).`); + } + return result; +} + +function notify(message, error = false) { + const toast = $("#toast"); + toast.textContent = message; + toast.classList.toggle("error", error); + toast.classList.remove("hidden"); + clearTimeout(state.toastTimer); + state.toastTimer = setTimeout(() => toast.classList.add("hidden"), error ? 12000 : 6000); +} + +function report(error) { + console.error(error); + notify(error.message || String(error), true); +} + +function changePage(page) { + if (!pages.has(page)) page = "overview"; + document.querySelectorAll(".page").forEach((element) => { + element.classList.toggle("hidden", element.id !== `page-${page}`); + }); + document.querySelectorAll(".nav-item").forEach((element) => { + element.classList.toggle("active", element.dataset.page === page); + }); + if (location.hash !== `#${page}`) location.hash = page; +} + +function canLeaveEdits() { + if (!state.dirty) return true; + if (!window.confirm("Discard the unsaved clip annotation?")) return false; + state.dirty = false; + return true; +} + +async function refreshLibrary() { + const data = await api("/bootstrap"); + state.bootstrap = data; + state.characters = data.characters; + state.jobs = data.jobs; + state.busy = data.busy; + const indicator = $("#backend-indicator"); + indicator.classList.toggle("ready", data.backend_available); + indicator.replaceChildren(); + indicator.append(document.createElement("i"), document.createTextNode( + data.backend_available ? "Local backend configured" : "Configure ACE-Step path", + )); + $("#connection-error").classList.toggle("hidden", data.source_available); + if (!data.source_available) { + $("#connection-error").textContent = "The recording library folder was not found. Update its path in Workspace settings."; + } + $("#settings-ace").value = data.settings.ace_root; + $("#settings-python").value = data.settings.ace_python; + $("#settings-source").value = data.settings.source_root; + $("#settings-workspace").value = data.settings.workspace; + const oldModel = $("#model-select").value; + $("#model-select").innerHTML = data.models.map((model) => + ``, + ).join(""); + if (data.models.some((model) => model.id === oldModel)) $("#model-select").value = oldModel; + if (!state.characters.some((character) => character.id === state.cid)) { + state.cid = state.characters[0]?.id || null; + state.sample = null; + } + renderLibrary(); +} + +function renderLibrary() { + $("#character-list").innerHTML = state.characters.map((character) => ` + `).join("") || empty("Your characters will appear here."); + $("#library-total").textContent = `${state.characters.length} CHARACTER${state.characters.length === 1 ? "" : "S"}`; + $("#library-grid").innerHTML = state.characters.map((character) => ` + `).join("") || empty("Create your first character to start building a voice library."); +} + +async function refreshCharacter() { + state.character = state.cid ? await api(`/characters/${state.cid}`) : null; + renderCharacter(); + renderJobs(); +} + +async function refreshAll() { + await refreshLibrary(); + await refreshCharacter(); +} + +async function selectCharacter(cid) { + if (cid === state.cid || !canLeaveEdits()) return; + state.cid = cid; + state.sample = null; + state.jobId = null; + $("#authorized").checked = false; + $("#command-preview").textContent = "Your command preview will appear here.\nPreviewing does not execute anything."; + renderLibrary(); + await refreshCharacter(); +} + +function renderCharacter() { + const item = state.character; + const prepared = item?.prepared; + const samples = prepared?.samples || []; + const recordings = item?.recordings || []; + const weights = (item?.artifacts || []).filter((artifact) => artifact.name.endsWith(".safetensors")); + $("#breadcrumb-name").textContent = item?.name || "Voice library"; + $("#hero-name").textContent = item?.name || "A place for every voice."; + $("#nav-count").textContent = recordings.length; + $("#stat-recordings").textContent = recordings.length; + $("#stat-duration").textContent = duration(item?.duration); + $("#stat-clips").textContent = `${prepared?.reviewed || 0} / ${samples.length}`; + $("#stat-models").textContent = weights.length; + $("#export-trigger").textContent = prepared?.metadata?.custom_tag || item?.trigger || "No character selected"; + $("#stage-source").textContent = recordings.length ? "RECORDINGS ADDED" : "ADD RECORDINGS"; + $("#stage-source").classList.toggle("success", recordings.length > 0); + $("#stage-review").textContent = samples.length && prepared.reviewed === samples.length ? "CLIPS REVIEWED" : "PREPARE & REVIEW"; + $("#stage-review").classList.toggle("success", samples.length > 0 && prepared.reviewed === samples.length); + $("#stage-train").textContent = weights.length ? "ADAPTER FILES SAVED" : "TRAIN WHEN READY"; + $("#stage-train").classList.toggle("success", weights.length > 0); + $("#source-count").textContent = `${recordings.length} FILES`; + $("#source-path").textContent = item?.source || "Create a character to add recordings."; + $("#source-list").innerHTML = recordings.map((recording) => ` +
${icon("wave")} +
${escapeHTML(recording.name)} + ${recording.error ? escapeHTML(recording.error) : `${duration(recording.duration)} · ${recording.sample_rate / 1000} kHz · ${recording.channels === 2 ? "Stereo" : "Mono"} · ${escapeHTML(recording.subtype)}`}
+ ${recording.error ? "" : ``} +
`).join("") || empty("No recordings yet. Add WAV, FLAC, or OGG files for this character."); + $("#profile-name").value = item?.name || ""; + $("#profile-trigger").value = item?.trigger || ""; + $("#profile-caption").value = item?.caption || ""; + $("#profile-language").value = item?.language || ""; + $("#review-count").textContent = samples.length + ? `${prepared.reviewed} / ${samples.length} REVIEWED` : "NO DATASET YET"; + const warnings = prepared?.warnings || []; + $("#dataset-warnings").classList.toggle("hidden", warnings.length === 0); + $("#dataset-warnings").textContent = warnings.join(" "); + if (!samples.some((sample) => sample.id === state.sample)) { + state.sample = samples.find((sample) => !sample.reviewed)?.id || samples[0]?.id || null; + } + renderClips(); + if (!state.dirty) renderEditor(); + renderArtifacts(); + renderReadiness(); + applyButtons(); +} + +function renderClips() { + const samples = state.character?.prepared?.samples || []; + $("#clip-list").innerHTML = samples.map((sample) => ` + `).join("") || empty("Prepare a dataset to review its clips here."); +} + +function renderEditor() { + const sample = state.character?.prepared?.samples.find((item) => item.id === state.sample); + $("#clip-heading").textContent = sample?.filename || "Choose a clip"; + $("#clip-duration").textContent = sample ? `${sample.duration.toFixed(1)} SECONDS` : "--"; + const audio = $("#clip-audio"); + audio.pause(); + if (sample) { + audio.src = `/api/characters/${state.cid}/samples/${encodeURIComponent(sample.id)}/audio`; + } else { + audio.removeAttribute("src"); + } + $("#clip-caption").value = sample?.caption || ""; + $("#clip-lyrics").value = sample?.lyrics || ""; + $("#clip-reviewed").checked = Boolean(sample?.reviewed); + applyButtons(); +} + +function renderArtifacts() { + const artifacts = state.character?.artifacts || []; + $("#artifact-list").innerHTML = artifacts.map((artifact) => ` +
${icon("box")} +
${escapeHTML(artifact.name)} + ${escapeHTML(artifact.relative)}
+ ${size(artifact.bytes)} + Download +
`).join("") || empty("No artifacts saved yet. Prepared datasets, job logs, SVC exports, and trained adapters will appear here."); +} + +function renderReadiness() { + const data = state.bootstrap; + const prepared = state.character?.prepared; + const samples = prepared?.samples || []; + const model = $("#model-select").value; + const checks = [ + [Boolean(data?.backend_available), "ACE-Step runtime path configured"], + [Boolean(data?.models.find((item) => item.id === model)?.available), "Selected XL checkpoint present"], + [samples.length > 0, `${samples.length} clips in the prepared dataset`], + [samples.length > 0 && prepared.reviewed === samples.length, `${prepared?.reviewed || 0} clips listened to and annotated`], + [Boolean(prepared?.ready && prepared.ready.model === model), "Tensors match this dataset and XL variant"], + [$("#authorized").checked, "Voice-use authorization confirmed"], + ]; + $("#readiness-list").innerHTML = checks.map(([complete, text], index) => ` +
  • ${complete ? icon("check") : index + 1}${escapeHTML(text)}
  • `, + ).join(""); + const complete = checks.filter(([done]) => done).length; + $("#readiness-pill").textContent = `${complete} / ${checks.length} READY`; + $("#readiness-pill").classList.toggle("success", complete === checks.length); +} + +function applyButtons() { + document.querySelectorAll(".requires-character").forEach((button) => { + button.disabled = !state.cid || state.busy; + }); + document.querySelectorAll(".add-character").forEach((button) => { button.disabled = state.busy; }); + $("#profile-form button").disabled = !state.cid || state.busy; + $("#settings-form button").disabled = state.busy; + $("#save-clip").disabled = !state.sample || state.busy; + $("#next-clip").disabled = !state.sample || state.busy; + document.querySelectorAll("#annotation-form input, #annotation-form textarea").forEach((field) => { + field.disabled = !state.sample || state.busy; + }); + document.querySelectorAll("#profile-form input").forEach((field) => { + field.disabled = !state.cid || state.busy; + }); +} + +function renderJobs() { + const filtered = state.jobs.filter((job) => job.character_id === state.cid); + if (!filtered.some((job) => job.id === state.jobId)) state.jobId = filtered[0]?.id || null; + $("#job-select").innerHTML = filtered.map((job) => ` + `, + ).join("") || ''; + const job = filtered.find((item) => item.id === state.jobId); + $("#job-title").textContent = job ? labels[job.action] || job.action : "Training console"; + $("#job-status").textContent = job?.status.toUpperCase() || "IDLE"; + $("#job-status").className = `pill ${job?.status === "failed" ? "failed" : ""}`; + $("#job-dot").className = `status-dot ${job?.status || ""}`; + const consoleElement = $("#job-log"); + const atEnd = consoleElement.scrollHeight - consoleElement.scrollTop - consoleElement.clientHeight < 60; + consoleElement.textContent = job + ? job.log.join("\n") + (job.error ? `\n\nERROR: ${job.error}` : "") + : "Ready when you are.\nNo jobs have been started for this character."; + if (atEnd) consoleElement.scrollTop = consoleElement.scrollHeight; + $("#job-time").textContent = job + ? `${new Date(job.started_at).toLocaleString()}${job.ended_at ? ` - ${job.status}` : " - running"}` + : "No elapsed time to report"; + applyButtons(); +} + +function jobOptions(action) { + const base = { + action, clip_seconds: Number($("#clip-seconds").value), silence_db: Number($("#silence-db").value), + }; + if (["prepare", "export_svc"].includes(action)) return base; + if (!$("#training-form").reportValidity()) throw new Error("Check the training settings."); + return { + ...base, model: $("#model-select").value, + epochs: Number($("#epochs").value), rank: Number($("#rank").value), + learning_rate: Number($("#learning-rate").value), accumulation: Number($("#accumulation").value), + authorized: $("#authorized").checked, + }; +} + +async function startJob(action) { + if (!state.cid) throw new Error("Create or select a character first."); + if (action === "prepare" && !canLeaveEdits()) return; + if (["train", "preprocess"].includes(action)) { + if (state.dirty) throw new Error("Save the current clip annotation before preprocessing or training."); + if (!$("#authorized").checked) throw new Error("Confirm voice-use authorization in the training recipe."); + if (!window.confirm(`Start ${labels[action].toLowerCase()} now? This launches a real GPU job in your ACE-Step environment.`)) return; + } + const job = await api(`/characters/${state.cid}/jobs`, { method: "POST", body: jobOptions(action) }); + state.jobId = job.id; + state.jobs.unshift(job); + state.busy = true; + renderJobs(); + changePage("training"); + notify(`${labels[action]} queued. Follow its output in the console.`); +} + +async function pollJobs() { + if (state.polling || !state.bootstrap) return; + state.polling = true; + try { + const data = await api("/jobs"); + const previous = new Map(state.jobs.map((job) => [job.id, job.status])); + const finished = data.jobs.filter((job) => + previous.has(job.id) && previous.get(job.id) !== job.status && ["completed", "failed"].includes(job.status), + ); + state.jobs = data.jobs; + state.busy = data.busy; + if (state.bootstrap.source_available) $("#connection-error").classList.add("hidden"); + renderJobs(); + for (const job of finished) { + notify(job.status === "failed" + ? `${labels[job.action]} failed: ${job.error}` + : `${labels[job.action]} completed.`, job.status === "failed"); + } + if (finished.length && !state.dirty) await refreshAll(); + } catch (error) { + $("#connection-error").textContent = `Connection to Voice Studio interrupted: ${error.message}`; + $("#connection-error").classList.remove("hidden"); + } finally { + state.polling = false; + } +} + +document.addEventListener("click", (event) => { + const page = event.target.closest("[data-page]"); + if (page) changePage(page.dataset.page); + const character = event.target.closest("[data-character]"); + if (character) selectCharacter(character.dataset.character).catch(report); + const clip = event.target.closest("[data-sample]"); + if (clip && canLeaveEdits()) { + state.sample = clip.dataset.sample; + renderClips(); + renderEditor(); + } + if (event.target.closest(".add-character")) { + $("#dialog-error").textContent = ""; + $("#character-form").reset(); + $("#character-dialog").showModal(); + $("#new-name").focus(); + } +}); + +$("#close-dialog").addEventListener("click", () => $("#character-dialog").close()); +$("#character-form").addEventListener("submit", async (event) => { + event.preventDefault(); + const button = event.target.querySelector('[type="submit"]'); + button.disabled = true; + try { + if (!canLeaveEdits()) return; + const result = await api("/characters", { method: "POST", body: { + name: $("#new-name").value.trim(), trigger: $("#new-trigger").value.trim(), + } }); + state.cid = result.id; + state.sample = null; + state.jobId = null; + $("#authorized").checked = false; + $("#character-dialog").close(); + await refreshAll(); + changePage("recordings"); + notify(`${result.name} has its own workspace. Add recordings to get started.`); + } catch (error) { + $("#dialog-error").textContent = error.message; + } finally { + button.disabled = false; + } +}); + +$("#profile-form").addEventListener("submit", async (event) => { + event.preventDefault(); + try { + if (!canLeaveEdits()) return; + await api(`/characters/${state.cid}`, { method: "PUT", body: { + name: $("#profile-name").value.trim(), trigger: $("#profile-trigger").value.trim(), + caption: $("#profile-caption").value.trim(), language: $("#profile-language").value.trim(), + } }); + await refreshAll(); + notify("Character identity saved. Existing clip annotations were preserved."); + } catch (error) { report(error); } +}); + +$("#upload-button").addEventListener("click", () => $("#upload-input").click()); +$("#upload-input").addEventListener("change", async (event) => { + const files = [...event.target.files]; + if (!files.length) return; + const form = new FormData(); + files.forEach((file) => form.append("files", file)); + $("#upload-button").disabled = true; + try { + const result = await api(`/characters/${state.cid}/recordings`, { method: "POST", body: form }); + await refreshAll(); + notify(`${result.saved.length} recording(s) added. Prepare a new dataset to include them.`); + } catch (error) { + report(error); + await refreshAll().catch(report); + } finally { + event.target.value = ""; + applyButtons(); + } +}); + +$("#annotation-form").addEventListener("input", () => { state.dirty = true; }); +$("#annotation-form").addEventListener("submit", async (event) => { + event.preventDefault(); + try { + await api(`/characters/${state.cid}/samples/${state.sample}`, { method: "PUT", body: { + dataset_version: state.character.prepared.version, + caption: $("#clip-caption").value.trim(), lyrics: $("#clip-lyrics").value.trim(), + reviewed: $("#clip-reviewed").checked, + } }); + state.dirty = false; + await refreshCharacter(); + notify("Clip saved. Any changed annotations require fresh preprocessing."); + } catch (error) { report(error); } +}); +$("#next-clip").addEventListener("click", () => { + if (!canLeaveEdits()) return; + const samples = state.character?.prepared?.samples || []; + const index = samples.findIndex((sample) => sample.id === state.sample); + state.sample = samples[(index + 1) % samples.length]?.id || null; + renderClips(); + renderEditor(); +}); + +$("#prepare-button").addEventListener("click", () => startJob("prepare").catch(report)); +$("#preprocess-button").addEventListener("click", () => startJob("preprocess").catch(report)); +$("#export-svc").addEventListener("click", () => startJob("export_svc").catch(report)); +$("#training-form").addEventListener("submit", (event) => { + event.preventDefault(); + startJob("train").catch(report); +}); +$("#authorized").addEventListener("change", renderReadiness); +$("#model-select").addEventListener("change", renderReadiness); +$("#job-select").addEventListener("change", (event) => { + state.jobId = event.target.value; + renderJobs(); +}); +$("#preview-recipe").addEventListener("click", async () => { + try { + const result = await api(`/characters/${state.cid}/recipe`, { method: "POST", body: jobOptions("train") }); + $("#command-preview").textContent = result.command; + } catch (error) { report(error); } +}); +$("#refresh-artifacts").addEventListener("click", () => refreshCharacter().catch(report)); +$("#settings-form").addEventListener("submit", async (event) => { + event.preventDefault(); + try { + if (!canLeaveEdits()) return; + await api("/settings", { method: "PUT", body: { + ace_root: $("#settings-ace").value.trim(), ace_python: $("#settings-python").value.trim(), + source_root: $("#settings-source").value.trim(), + } }); + $("#authorized").checked = false; + await refreshAll(); + notify("Workspace paths saved."); + } catch (error) { report(error); } +}); + +window.addEventListener("hashchange", () => changePage(location.hash.slice(1))); +window.addEventListener("beforeunload", (event) => { + if (state.dirty) { + event.preventDefault(); + event.returnValue = ""; + } +}); +changePage(location.hash.slice(1)); +refreshAll().catch((error) => { + $("#connection-error").textContent = `Could not load the local workspace: ${error.message}. Start Voice Studio with its PowerShell launcher.`; + $("#connection-error").classList.remove("hidden"); + report(error); +}); +setInterval(pollJobs, 2500); diff --git a/AceStepXL-Training/src/voice_studio/static/index.html b/AceStepXL-Training/src/voice_studio/static/index.html new file mode 100644 index 0000000..88b828b --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/static/index.html @@ -0,0 +1,139 @@ + + + + + + + Voice Studio - Character Training + + + + + + + + +
    +
    + +
    Checking workspaceVS
    +
    +
    + +
    +

    THE VOICE BEHIND THE MUSIC

    Your next voice starts here.

    Build a character. Shape its sound. Make it your own.

    +
    +
    VOICE CHARACTER WORKSPACE

    A place for every voice.

    From your recordings to a recognisable vocal identity.
    One library, two distinct training paths.

    + +
    +
    +
    Source recordings0Original files preserved
    +
    Source audio0:00In this character's library
    +
    Reviewed clips0 / 0Listening & annotation
    +
    Adapter weight files0Actual saved artifacts
    +
    +

    A clear path to your character

    No hidden steps. No automatic training.

    +
    +
    01ADD RECORDINGS

    Start with a clean voice

    Add isolated vocal takes. Keep accompaniment, heavy reverb, and other singers out of the training set.

    +
    02PREPARE & REVIEW

    Give the details a listen

    Create short clips, check each one, and add accurate lyrics or wordless-vocal descriptions for ACE-Step.

    +
    03TRAIN WHEN READY

    Make the character yours

    Train an XL adapter for new songs, or export a dataset for a separate RVC voice-conversion model.

    +
    +

    Your character library

    Each voice has its own data, training history, and exports.

    0 CHARACTERS
    +
    +
    + + + + + + + + +
    VOICE STUDIO · Made for the voice behind the song.Local files. Explicit actions. Your control.
    +
    +
    + +

    EVERY VOICE HAS A STORY

    Meet your next character.

    Give this voice its own place in your library. Add recordings when you're ready.

    A unique tag to use in ACE-Step generation captions. Letters, numbers, hyphens, and underscores.

    + + + diff --git a/AceStepXL-Training/src/voice_studio/static/styles.css b/AceStepXL-Training/src/voice_studio/static/styles.css new file mode 100644 index 0000000..e4cf2b1 --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/static/styles.css @@ -0,0 +1,254 @@ +:root { + --bg: #f5f4f9; --paper: #fff; --ink: #252238; --muted: #7c788e; + --purple: #7755d8; --purple-dark: #5d3cbb; --line: #eae7f1; + --lavender: #eee8fd; --mint: #e6f3ee; --green: #36876c; + --radius: 16px; --shadow: 0 5px 24px #30224b04; + font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif; + color: var(--ink); background: var(--bg); font-size: 14px; +} +* { box-sizing: border-box; } +body { margin: 0; } +button, input, select, textarea { font: inherit; } +button, a, summary, select { -webkit-tap-highlight-color: transparent; } +button { cursor: pointer; } +button:disabled { opacity: .45; cursor: not-allowed; } +button, a, input, textarea, select, summary { outline-offset: 4px; } +:focus-visible { outline: 2px solid var(--purple); } +button { transition: background .16s, transform .16s, box-shadow .16s; } +button:active:not(:disabled) { transform: translateY(1px); } +a { color: var(--purple); } +h1, h2, h3, p { margin: 0; } +h1 { font-size: clamp(25px, 2.2vw, 34px); letter-spacing: -1.1px; font-weight: 650; margin-bottom: 10px; } +h2 { font-size: 19px; letter-spacing: -.45px; font-weight: 650; } +h3 { font-size: 15px; font-weight: 650; } +p { line-height: 1.75; } +small { color: var(--muted); } +.hidden { display: none !important; } +.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; } +.icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; } +.sidebar { width: 252px; background: #fbfafe; border-right: 1px solid var(--line); position: fixed; inset: 0 auto 0 0; padding: 34px 18px 20px; display: flex; flex-direction: column; z-index: 20; } +.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); font-size: 24px; font-weight: 750; letter-spacing: -1px; margin: 0 12px 43px; } +.brand-light { font-weight: 400; } +.brand small { display: block; font-size: 8px; letter-spacing: 2.3px; margin-top: 5px; font-weight: 600; } +.brand-mark { display: grid; place-items: center; width: 39px; height: 43px; background: linear-gradient(145deg,#9977ed,#7151c5); color: white; border-radius: 12px; box-shadow: 0 5px 12px #7755d830; } +.brand-mark .icon { width: 25px; height: 25px; } +.workspace-label, .library-label { color: #9691a8; font-size: 10px; letter-spacing: 1.5px; font-weight: 650; padding: 0 14px; } +.workspace-label { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; } +.local-dot { color: #888095; font-size: 8px; letter-spacing: .8px; display: flex; align-items: center; gap: 5px; } +.local-dot::before { content: ""; width: 5px; height: 5px; background: #6aa58a; border-radius: 50%; } +.navigation { display: flex; flex-direction: column; gap: 5px; } +.nav-item { border: 0; background: transparent; width: 100%; display: flex; align-items: center; gap: 12px; color: #767087; padding: 13px 14px; text-align: left; border-radius: 9px; font-size: 12px; font-weight: 550; } +.nav-item:hover { background: #f0ecf7; } +.nav-item.active { background: #eee7fb; color: var(--purple); } +.nav-count { background: #fff9; font-size: 10px; padding: 2px 6px; border-radius: 5px; margin-left: auto; } +.library-label { display: flex; align-items: center; justify-content: space-between; margin: 34px 0 9px; padding-right: 5px; } +.icon-button { border: 0; background: transparent; color: var(--muted); padding: 6px; border-radius: 7px; display: inline-grid; place-items: center; font-size: 24px; } +.icon-button:hover { color: var(--purple); background: var(--lavender); } +.character-list { overflow-y: auto; min-height: 40px; max-height: 28vh; } +.character-item { display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 10px 13px; border-radius: 9px; text-align: left; width: 100%; color: #777184; } +.character-item:hover, .character-item.selected { background: #f1edf8; color: var(--ink); } +.avatar { width: 34px; height: 34px; display: grid; place-items: center; background: #e9e2f7; color: #7d62ab; border-radius: 10px; font-weight: 650; font-size: 12px; flex-shrink: 0; } +.character-item:nth-child(3n+2) .avatar { background: #e4eee9; color: #5c8875; } +.character-item:nth-child(3n) .avatar { background: #f6e9e3; color: #b88d77; } +.character-text { overflow: hidden; } +.character-text strong { display: block; font-size: 11px; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; } +.character-text small { display: block; font-size: 10px; margin-top: 4px; } +.sidebar-add { margin: 10px 12px 0; display: flex; align-items: center; gap: 9px; border: none; background: none; font-size: 11px; color: #9488ab; padding: 8px 0; } +.sidebar-add .icon { width: 15px; height: 15px; } +.sidebar-bottom { margin-top: auto; padding-top: 20px; } +.privacy-card { background: #f0ecf7; border: 1px solid #e8e1f2; border-radius: 12px; padding: 14px 10px; margin: 0 4px 18px; display: flex; align-items: flex-start; gap: 8px; } +.privacy-icon { color: #9983b9; padding-top: 2px; } +.privacy-card strong { font-size: 10px; color: #6b5c82; font-weight: 600; } +.privacy-card p { font-size: 9px; color: #9b8dab; margin-top: 3px; } +.sidebar-version { padding: 21px 14px 0; display: flex; justify-content: space-between; font-size: 8px; letter-spacing: 1px; color: #aaa4b9; } +.main-shell { margin-left: 252px; } +.topbar { height: 77px; display: flex; align-items: center; justify-content: space-between; padding: 0 42px; border-bottom: 1px solid var(--line); background: #ffffffa8; } +.breadcrumb { display: flex; align-items: center; gap: 13px; font-size: 11px; color: #a19aae; } +.breadcrumb strong { color: #6d647e; font-weight: 500; } +.breadcrumb span { color: #c3bace; } +.topbar-right { display: flex; align-items: center; gap: 22px; } +.connection { font-size: 10px; color: #92899e; display: flex; align-items: center; gap: 7px; } +.connection i { width: 6px; height: 6px; border-radius: 50%; background: #aaa2b8; } +.connection.ready i { background: #5fa486; } +.avatar.mini { width: 31px; height: 31px; font-size: 10px; background: #f0eafa; } +main { padding: 36px 42px 0; max-width: 1550px; margin: auto; } +.page-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin: 3px 0 28px; } +.eyebrow { font-size: 9px; letter-spacing: 2px; color: #9b8cb4; font-weight: 650; margin-bottom: 12px; } +.muted { color: var(--muted); font-size: 12px; } +.button { border: 1px solid transparent; padding: 11px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; border-radius: 9px; font-size: 11px; font-weight: 600; text-decoration: none; white-space: nowrap; line-height: 1.5; } +.button .icon { width: 16px; height: 16px; } +.button.primary { background: var(--purple); color: #fff; box-shadow: 0 4px 11px #7755d81c; } +.button.primary:hover { background: var(--purple-dark); } +.button.secondary { background: white; color: #716584; border-color: #e4ddeb; } +.button.secondary:hover { background: #f8f5fd; } +.button.white { background: #fff; color: #7959bc; } +.button.ghost-light { background: #ffffff0d; color: #eee6ff; border-color: #ffffff24; } +.full { width: 100%; } +.text-button { display: inline-flex; align-items: center; gap: 8px; font-size: 10px; font-weight: 600; color: var(--purple); border: none; background: transparent; padding: 5px 0; } +.text-button .icon { width: 14px; height: 14px; } +.hero { display: flex; justify-content: space-between; align-items: center; min-height: 268px; padding: 33px 38px; border-radius: 18px; background: linear-gradient(112deg,#8061bf,#9672cc 57%,#c1a3df); position: relative; overflow: hidden; box-shadow: 0 12px 26px #71519215; } +.hero::after { content: ""; position: absolute; width: 500px; height: 500px; border-radius: 50%; border: 1px solid #ffffff0b; right: -40px; top: -130px; pointer-events: none; } +.hero-content { z-index: 1; } +.hero h2 { color: #fff; font-size: clamp(24px,2.3vw,34px); letter-spacing: -1px; margin: 18px 0 10px; overflow-wrap: anywhere; } +.hero p { color: #eee5fc; font-size: 12px; line-height: 1.9; } +.hero-actions { display: flex; gap: 12px; margin-top: 23px; flex-wrap: wrap; } +.pill { border: 1px solid var(--line); background: #faf9fc; color: #9690a4; padding: 5px 8px; border-radius: 6px; font-size: 8px; font-weight: 600; letter-spacing: .7px; white-space: nowrap; display: inline-block; line-height: 1.3; } +.hero-pill { background: #ffffff15; color: #f1eafa; border-color: #ffffff25; font-size: 8px; letter-spacing: 1.5px; } +.pill.accent { background: var(--lavender); border-color: #e6ddfa; color: var(--purple); } +.pill.success { background: var(--mint); border-color: #d7e9e1; color: var(--green); } +.pill.failed { background: #fbe8e8; color: #b65353; border-color: #f2d5d5; } +.voice-art { width: 250px; height: 210px; position: relative; flex-shrink: 0; display: grid; place-items: center; margin-right: 20px; } +.orbit { position: absolute; border: 1px solid #ffffff25; border-radius: 50%; } +.orbit-one { width: 205px; height: 205px; } +.orbit-two { width: 170px; height: 170px; border-color: #ffffff35; } +.orbit-three { width: 135px; height: 135px; border-color: #ffffff50; } +.voice-core { width: 106px; height: 106px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%,#e2d1f277,#ffffff12); border: 1px solid #fff6; box-shadow: 0 0 70px #fff2,inset 0 0 18px #ffffff18; backdrop-filter: blur(10px); } +.voice-core svg { width: 65px; height: 65px; fill: none; stroke: #fff; stroke-width: 1.2; stroke-linecap: round; } +.art-label { position: absolute; bottom: -9px; font-size: 7px; letter-spacing: 2px; color: #f0dffa; } +.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin: 22px 0 34px; } +.stat { display: flex; gap: 13px; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 19px 16px; box-shadow: var(--shadow); align-items: flex-start; } +.stat-icon, .export-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; } +.lavender { background: var(--lavender); color: #9573d1; } +.peach { background: #fbede5; color: #dca57d; } +.mint { background: var(--mint); color: #77a992; } +.blue { background: #e9effb; color: #86a0cf; } +.stat-label { font-size: 9px; color: #9b94a8; display: block; padding-top: 1px; } +.stat strong { display: block; font-size: 23px; font-weight: 600; letter-spacing: -.7px; margin: 6px 0 5px; } +.stat small { font-size: 8px; display: block; } +.section-heading { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 17px; gap: 20px; } +.section-heading h2 { font-size: 16px; margin-bottom: 5px; } +.section-heading p { font-size: 10px; } +.workflow-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 18px; } +.step-card { background: #fff; padding: 22px; border: 1px solid var(--line); border-radius: 13px; position: relative; } +.step-number { position: absolute; top: 20px; right: 20px; color: #e5dff0; font-size: 25px; font-weight: 600; } +.step-card h3 { margin-top: 22px; margin-bottom: 10px; } +.step-card p { font-size: 11px; color: #8e879c; margin-bottom: 18px; line-height: 1.85; } +.library-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; } +.library-card { border: 1px solid var(--line); background: #fff; border-radius: 13px; padding: 20px; display: flex; align-items: center; gap: 13px; text-align: left; color: var(--ink); min-width: 0; } +.library-card:hover { border-color: #cbb8eb; box-shadow: 0 5px 20px #7755d80b; } +.library-card .avatar { width: 45px; height: 45px; border-radius: 12px; } +.library-card h3 { font-size: 12px; overflow-wrap: anywhere; } +.library-card p { font-size: 10px; margin-top: 4px; color: #a197ad; } +.library-card .icon { margin-left: auto; color: #b7aac9; width: 16px; } +.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 25px; box-shadow: var(--shadow); } +.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 22px; } +.panel-heading h2 { font-size: 16px; } +.notice { padding: 14px 18px; border: 1px solid #e5ddf3; background: #f0ebf8; color: #837098; font-size: 11px; line-height: 1.8; border-radius: 10px; margin-bottom: 22px; overflow-wrap: anywhere; } +.notice strong { color: #67547f; font-weight: 650; } +.notice.warning { background: #fcf5e9; color: #9b835b; border-color: #f0e5d0; } +.notice.warning strong { color: #8b724b; } +.notice.danger { background: #fceeee; border-color: #f0d7d7; color: #af5353; } +.dataset-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; margin-top: 20px; } +.prep-panel { background: linear-gradient(135deg,#fff,#f8f4fe); } +.prep-panel h2 { font-size: 23px; margin-bottom: 15px; line-height: 1.4; } +.prep-panel .form-grid { margin: 24px 0 8px; } +.prep-panel .field-help { margin-top: 10px; text-align: center; } +.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; } +label { display: flex; flex-direction: column; gap: 8px; font-size: 10px; font-weight: 600; color: #766a89; margin-bottom: 18px; } +input, select, textarea { color: #635870; background: #fcfbfe; border: 1px solid #e7e1ee; border-radius: 8px; padding: 10px 12px; width: 100%; font-size: 12px; min-width: 0; } +textarea { resize: vertical; line-height: 1.7; } +input:focus, select:focus, textarea:focus { border-color: #bda5e2; background: white; } +input[readonly] { color: #a79bb5; background: #f7f5fa; } +.form-grid label { margin: 0; } +.field-help { color: #a296ae; font-size: 10px; line-height: 1.8; margin: -8px 0 18px; font-weight: 400; } +.span-two { grid-column: span 2; } +.span-all { grid-column: 1 / -1; } +.align-end { display: flex; align-items: end; } +.profile-panel summary { color: #7f6a96; cursor: pointer; font-size: 12px; font-weight: 600; } +.profile-panel[open] summary { margin-bottom: 24px; } +.profile-panel { padding: 20px 25px; } +.source-list { max-height: 290px; overflow-y: auto; } +.source-row { display: flex; gap: 12px; align-items: center; padding: 13px 0; border-bottom: 1px solid #f0ecf5; } +.source-row:last-child { border: 0; } +.source-row .source-details { min-width: 0; flex: 1; } +.source-row strong { font-size: 10px; display: block; overflow-wrap: anywhere; font-weight: 600; } +.source-row small { font-size: 9px; margin-top: 5px; display: block; color: #a69bb2; } +.source-row audio { height: 28px; width: 170px; max-width: 43%; } +.source-row .file-icon { background: #f2edf9; color: #b19bcd; width: 30px; height: 34px; border-radius: 6px; display: grid; place-items: center; } +.source-row .icon { width: 16px; height: 16px; } +.path-text { font: 9px/1.8 Consolas, monospace; color: #aaa0b6; overflow-wrap: anywhere; margin-top: 16px; } +.review-grid { display: grid; grid-template-columns: .8fr 1.4fr; gap: 22px; } +.clip-panel { padding: 10px; } +.clip-list { max-height: 540px; overflow-y: auto; } +.clip-item { width: 100%; padding: 13px 14px; border: none; background: none; border-radius: 9px; color: #8a7f97; display: flex; align-items: center; gap: 12px; text-align: left; } +.clip-item.selected { background: #f0eafa; color: var(--purple); } +.clip-item:hover { background: #f7f3fc; } +.clip-item strong { font-size: 11px; font-weight: 600; } +.clip-item small { margin-left: auto; font-size: 9px; } +.clip-item .icon { width: 15px; height: 15px; color: #b2a1c6; } +.clip-item.reviewed .icon { color: #6ea58b; } +.annotation-panel audio { width: 100%; margin: 0 0 25px; height: 40px; } +.check-label { flex-direction: row; align-items: flex-start; font-size: 11px; font-weight: 400; line-height: 1.8; gap: 10px; } +.check-label input { width: 15px; height: 15px; margin: 3px 0 0; accent-color: var(--purple); flex-shrink: 0; } +.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; } +.training-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 22px; } +.training-aside { display: flex; flex-direction: column; gap: 22px; } +.training-grid .form-grid { margin: 20px 0; } +.recipe-footnote { display: flex; align-items: center; gap: 12px; padding: 15px; background: #f7f4fb; color: #a08bb7; border-radius: 9px; font-size: 10px; line-height: 1.9; margin-bottom: 22px; } +.authorization { border-top: 1px solid var(--line); padding-top: 20px; margin-bottom: 20px; } +#training-form > .field-help:last-child { margin: 15px 0 0; } +.checklist { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-direction: column; gap: 18px; } +.checklist li { display: flex; align-items: center; gap: 10px; color: #a196ad; font-size: 11px; } +.checklist .check-circle { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: #f1edf6; color: #b7a9c7; font-size: 9px; } +.checklist li.complete { color: #728b7e; } +.checklist li.complete .check-circle { background: #e9f4ed; color: #6d9f82; } +.check-circle .icon { width: 12px; height: 12px; } +.readiness .field-help { margin: 0; } +.command-panel { flex: 1; } +.command-panel pre { font: 10px/1.9 Consolas, monospace; color: #9b8aad; padding: 16px; border-radius: 8px; border: 1px dashed #e5dced; background: #fbf9fe; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 190px; overflow-y: auto; } +.log-panel { border: 1px solid #332e42; border-radius: 13px; background: #24202f; margin-top: 25px; overflow: hidden; } +.log-toolbar { background: #2d273a; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 15px; } +.log-toolbar > div { display: flex; align-items: center; gap: 10px; } +.log-toolbar strong { font-size: 11px; color: #c1b5d2; } +.log-toolbar .pill { background: #ffffff08; color: #a999bd; border-color: #ffffff12; font-size: 7px; } +.log-toolbar select { width: 210px; background: #342d43; border-color: #494056; color: #b4a5c6; font-size: 9px; padding: 7px 9px; } +.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #81748f; display: inline-block; } +.status-dot.running { background: #af91ec; box-shadow: 0 0 0 4px #af91ec16; } +.status-dot.completed { background: #88b79a; } +.status-dot.failed { background: #dd8c8c; } +#job-log { font: 11px/1.9 Consolas, monospace; color: #b6a8c7; padding: 20px; margin: 0; min-height: 190px; max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; } +.log-footer { padding: 12px 20px; border-top: 1px solid #ffffff07; display: flex; justify-content: space-between; gap: 15px; color: #776987; font-size: 9px; } +.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; } +.export-card { position: relative; padding: 30px; } +.export-icon { width: 48px; height: 48px; margin-bottom: 24px; border-radius: 13px; } +.export-icon .icon { width: 24px; height: 24px; } +.export-card h2 { font-size: 24px; margin-bottom: 15px; } +.export-card > p:not(.field-help) { color: #94879f; font-size: 12px; line-height: 1.9; } +.format-tags { display: flex; gap: 8px; margin: 22px 0; flex-wrap: wrap; } +.format-tags span { font: 9px Consolas, monospace; color: #a48db9; background: #f7f3fb; border: 1px solid #eee7f4; padding: 7px 10px; border-radius: 6px; } +.export-note { padding: 16px; border: 1px solid #ece5f3; border-radius: 9px; margin-bottom: 23px; background: #fcfafe; } +.export-note strong { font-size: 11px; font-weight: 600; color: #8d76a3; overflow-wrap: anywhere; } +.export-note small { display: block; margin-top: 5px; font-size: 9px; } +.export-card .field-help { margin: 17px 0 0; } +.artifact-list { padding: 8px 25px; } +.artifact-row { display: flex; gap: 15px; align-items: center; border-bottom: 1px solid var(--line); padding: 17px 0; } +.artifact-row:last-child { border-bottom: none; } +.artifact-detail { flex: 1; min-width: 0; } +.artifact-detail strong { display: block; font-size: 11px; font-weight: 600; } +.artifact-detail small { display: block; margin-top: 5px; font-size: 9px; overflow-wrap: anywhere; } +.artifact-size { font-size: 10px; color: #b4a7bf; white-space: nowrap; } +.settings-panel { max-width: 800px; } +.settings-panel input { font-family: Consolas, monospace; } +.setup-notes { margin-top: 25px; } +.setup-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 30px; margin-top: 24px; } +.setup-grid h3 { font-size: 12px; margin-bottom: 10px; } +.setup-grid p { font-size: 11px; color: #a396ac; line-height: 1.9; } +.empty-state { padding: 35px 20px; text-align: center; color: #b4a7bf; font-size: 11px; line-height: 1.9; width: 100%; } +.library-grid > .empty-state { grid-column: 1 / -1; border: 1px dashed #dfd5ea; border-radius: 12px; } +.main-footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px 0 22px; margin-top: 30px; border-top: 1px solid var(--line); font-size: 8px; color: #b8adc4; } +.main-footer > span:first-child { letter-spacing: .4px; } +.footer-dot { padding: 0 8px; } +dialog { border: 1px solid #e9e0f3; border-radius: 20px; width: min(480px,calc(100vw - 32px)); padding: 32px; color: var(--ink); box-shadow: 0 30px 100px #26173730; } +dialog::backdrop { background: #25193260; backdrop-filter: blur(5px); } +.dialog-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; } +dialog h2 { font-size: 26px; letter-spacing: -.8px; } +dialog .muted { margin: 15px 0 24px; } +.optional { font-size: 9px; font-weight: 400; color: #b5a7c3; } +.form-error { font-size: 11px; color: #b95b62; margin-bottom: 15px; } +.toast { position: fixed; bottom: 25px; right: 30px; background: #fff; border: 1px solid #ded3ec; color: #78618e; box-shadow: 0 10px 45px #2a153b1a; padding: 15px 22px; border-radius: 12px; z-index: 100; font-size: 12px; max-width: min(500px,calc(100vw - 40px)); line-height: 1.7; } +.toast.error { color: #ad525d; border-color: #efcdd1; } +@media (min-width: 1600px) { main { padding-top: 44px; } .hero { min-height: 295px; } .stat { padding: 24px 20px; } } +@media (max-width: 1200px) { .sidebar { width: 220px; padding-left: 12px; padding-right: 12px; } .main-shell { margin-left: 220px; } main { padding: 28px 25px 0; } .topbar { padding: 0 25px; } .stat-grid { grid-template-columns: repeat(2,1fr); } .hero { padding: 30px; } .voice-art { width: 190px; margin-right: 0; } .workflow-grid { gap: 12px; } .step-card { padding: 18px; } .library-grid { grid-template-columns: repeat(2,1fr); } .dataset-grid,.training-grid { grid-template-columns: 1fr; } .source-list { max-height: 250px; } } +@media (max-width: 820px) { .sidebar { width: 78px; padding: 25px 10px; } .brand { margin: 0 7px 35px; } .brand > span:last-child,.workspace-label,.library-label,.character-list,.sidebar-add,.privacy-card,.sidebar-version,.nav-count { display: none; } .nav-item { font-size: 0; justify-content: center; padding: 14px; } .nav-item .icon { width: 21px; height: 21px; } .main-shell { margin-left: 78px; } .hero h2 { font-size: 28px; } .voice-art { display: none; } .workflow-grid { grid-template-columns: 1fr; } .step-card p { max-width: 90%; } .step-card h3 { margin-top: 18px; } .export-grid,.review-grid { grid-template-columns: 1fr; } .clip-list { max-height: 230px; } .setup-grid { grid-template-columns: 1fr; gap: 20px; } .page-heading { align-items: flex-start; } .page-heading > .pill { display: none; } .log-toolbar { flex-wrap: wrap; } .log-toolbar select { width: 100%; } .topbar { height: 65px; } .main-footer > span:last-child { display: none; } } +@media (max-width: 540px) { main { padding: 23px 16px 0; } .topbar { padding: 0 16px; } .connection { font-size: 0; gap: 0; } .topbar-right { gap: 12px; } .breadcrumb { font-size: 9px; gap: 8px; } .page-heading { flex-wrap: wrap; gap: 12px; } h1 { font-size: 25px; } .hero { padding: 27px 22px; } .hero h2 { font-size: 25px; } .hero p { font-size: 11px; } .hero-actions { gap: 8px; } .hero-actions .button { font-size: 10px; padding: 10px; } .stat-grid { gap: 10px; } .stat { flex-direction: column; padding: 15px; gap: 10px; } .stat strong { font-size: 22px; } .stat-label { font-size: 9px; } .library-grid { grid-template-columns: 1fr; } .panel { padding: 20px; } .clip-panel { padding: 8px; } .form-grid { grid-template-columns: 1fr; } .span-two { grid-column: auto; } .source-row { flex-wrap: wrap; } .source-row audio { width: 100%; max-width: 100%; } .source-row .source-details { flex-basis: 70%; } .section-heading { align-items: flex-start; } .artifact-row { flex-wrap: wrap; gap: 10px; } .artifact-size { display: none; } .artifact-detail { flex-basis: 80%; } .log-footer { flex-direction: column; } } +@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } } diff --git a/AceStepXL-Training/src/voice_studio/studio.py b/AceStepXL-Training/src/voice_studio/studio.py new file mode 100644 index 0000000..c12da32 --- /dev/null +++ b/AceStepXL-Training/src/voice_studio/studio.py @@ -0,0 +1,549 @@ +from __future__ import annotations + +import hashlib +import json +import math +import os +import re +import subprocess +import threading +import traceback +import uuid +import zipfile +from datetime import datetime, timezone +from pathlib import Path +from typing import Callable + +import numpy as np +import soundfile as sf +from scipy.signal import resample_poly + +ROOT = Path(__file__).resolve().parents[2] +WORKSPACE = Path(os.environ.get("VOICE_STUDIO_WORKSPACE", str(ROOT / "workspace"))).resolve() +AUDIO_SUFFIXES = {".wav", ".flac", ".ogg"} +MODELS = { + "acestep-v15-xl-sft": "xl_sft", + "acestep-v15-xl-turbo": "xl_turbo", + "acestep-v15-xl-base": "xl_base", +} + + +def now() -> str: + return datetime.now(timezone.utc).isoformat(timespec="seconds") + + +def write_json(path: Path, value: object) -> None: + path.parent.mkdir(parents=True, exist_ok=True) + temporary = path.with_name(f".{path.name}.{uuid.uuid4().hex}.tmp") + temporary.write_text(json.dumps(value, indent=2, ensure_ascii=False), encoding="utf-8") + temporary.replace(path) + + +def read_json(path: Path) -> dict: + return json.loads(path.read_text(encoding="utf-8")) + + +def fingerprint(path: Path) -> str: + return hashlib.sha256(path.read_bytes()).hexdigest() + + +def identifier(path: Path) -> str: + return hashlib.sha256(os.path.normcase(str(path.resolve())).encode()).hexdigest()[:16] + + +def slug(value: str) -> str: + result = re.sub(r"[^a-zA-Z0-9_-]+", "-", value.strip()).strip("-")[:64] + if not result or result in {".", ".."}: + raise ValueError("Use a name containing letters or numbers.") + if result.upper().split(".")[0] in { + "CON", "PRN", "AUX", "NUL", *(f"COM{i}" for i in range(1, 10)), + *(f"LPT{i}" for i in range(1, 10)), + }: + raise ValueError("This name is reserved by Windows.") + return result + + +def settings() -> dict: + saved = read_json(WORKSPACE / "settings.json") if (WORKSPACE / "settings.json").is_file() else {} + ace = Path(saved.get("ace_root", os.environ.get("ACESTEP_ROOT", r"D:\ai\ACE-Step-1.5"))).resolve() + return { + "ace_root": str(ace), + "ace_python": saved.get("ace_python", str(ace / ".venv" / "Scripts" / "python.exe")), + "source_root": saved.get( + "source_root", os.environ.get("VOICE_STUDIO_SOURCE", str(ROOT.parent / "Voice Characters")) + ), + "workspace": str(WORKSPACE), + } + + +def inventory(source: Path) -> list[dict]: + recordings = [] + for path in sorted(source.rglob("*")): + if not path.is_file() or path.suffix.lower() not in AUDIO_SUFFIXES: + continue + entry = { + "id": identifier(path), "name": str(path.relative_to(source)), + "bytes": path.stat().st_size, "path": str(path), + } + try: + info = sf.info(str(path)) + entry.update(duration=round(info.duration, 3), sample_rate=info.samplerate, + channels=info.channels, subtype=info.subtype, error=None) + except (RuntimeError, sf.LibsndfileError) as exc: + entry.update(duration=0, sample_rate=0, channels=0, subtype="", error=str(exc)) + recordings.append(entry) + return recordings + + +def characters() -> list[dict]: + source_root = Path(settings()["source_root"]) + if not source_root.is_dir(): + return [] + result = [] + for source in sorted(source_root.iterdir()): + if not source.is_dir() or source.name.startswith("."): + continue + cid = identifier(source) + config_path = WORKSPACE / cid / "character.json" + config = read_json(config_path) if config_path.is_file() else {} + files = inventory(source) + result.append({ + "id": cid, "name": config.get("name", source.name), "source": str(source.resolve()), + "trigger": config.get("trigger") or re.sub(r"[^a-zA-Z0-9_-]+", "-", source.name).strip("-")[:64] or f"voice-{cid}", + "caption": config.get("caption", "Solo sung vocal performance."), + "language": config.get("language", "unknown"), "recordings": files, + "duration": round(sum(item["duration"] for item in files), 2), + "dataset": config.get("dataset"), "created_at": config.get("created_at"), + }) + return result + + +def character(cid: str) -> dict: + for item in characters(): + if item["id"] == cid: + return item + raise FileNotFoundError("Voice character not found. Refresh the character library.") + + +def save_character(item: dict) -> None: + stored = {key: item.get(key) for key in ( + "name", "trigger", "caption", "language", "dataset", "created_at" + )} + write_json(WORKSPACE / item["id"] / "character.json", stored) + + +def create_character(name: str, trigger: str) -> dict: + folder_name = slug(name) + tag = slug(trigger or folder_name) + source = Path(settings()["source_root"]) / folder_name + source.mkdir(parents=True, exist_ok=False) + item = character(identifier(source)) + item.update(name=name.strip(), trigger=tag, created_at=now()) + save_character(item) + return item + + +def dataset_path(item: dict) -> Path: + if not item.get("dataset"): + raise ValueError("Prepare a dataset for this character first.") + path = (WORKSPACE / item["id"] / item["dataset"]).resolve() + if not path.is_relative_to(WORKSPACE / item["id"]) or not path.is_file(): + raise ValueError("The prepared dataset is missing or outside this character's workspace.") + return path + + +def dataset_view(item: dict) -> dict: + if not item.get("dataset"): + return {"samples": [], "ready": False, "reviewed": 0, "duration": 0} + path = dataset_path(item) + data = read_json(path) + ready_file = path.parent / "ready.json" + ready = read_json(ready_file) if ready_file.is_file() else {} + return { + **data, "path": str(path), "version": path.parent.name, + "reviewed": sum(bool(s.get("reviewed")) for s in data["samples"]), + "duration": round(sum(s["duration"] for s in data["samples"]), 2), + "ready": ready if ready.get("dataset_sha256") == fingerprint(path) else False, + } + + +def segment_ranges(audio: np.ndarray, rate: int, max_seconds: float, + silence_db: float) -> list[tuple[int, int]]: + window = max(1, round(rate * 0.02)) + count = math.ceil(len(audio) / window) + energy = np.array([ + np.sqrt(np.mean(np.square(audio[i * window:(i + 1) * window], dtype=np.float64))) + for i in range(count) + ]) + active = np.flatnonzero(energy > 10 ** (silence_db / 20)) + if not len(active): + return [] + groups: list[tuple[int, int]] = [] + start = previous = int(active[0]) + for index in active[1:]: + index = int(index) + if index - previous > 18: + groups.append((start, previous + 1)) + start = index + previous = index + groups.append((start, previous + 1)) + padded: list[tuple[int, int]] = [] + for start, end in groups: + begin, finish = max(0, (start - 6) * window), min(len(audio), (end + 6) * window) + if padded and begin <= padded[-1][1]: + padded[-1] = (padded[-1][0], finish) + else: + padded.append((begin, finish)) + maximum = max(window, int(max_seconds * rate)) + minimum = int(1.5 * rate) + result: list[tuple[int, int]] = [] + for begin, finish in padded: + while finish - begin > maximum: + target = begin + maximum + lo = max(begin + minimum, target - round(rate)) + candidates = energy[math.ceil(lo / window):target // window] + cut = ((math.ceil(lo / window) + int(np.argmin(candidates))) * window + if len(candidates) else target) + if finish - cut < minimum: + cut = begin + (finish - begin) // 2 + result.append((begin, cut)) + begin = cut + if finish - begin >= minimum: + result.append((begin, finish)) + return result + + +def converted_audio(audio: np.ndarray, source_rate: int, target_rate: int) -> np.ndarray: + if source_rate == target_rate: + result = audio + else: + common = math.gcd(source_rate, target_rate) + result = resample_poly(audio, target_rate // common, source_rate // common, axis=0) + peak = float(np.max(np.abs(result))) if len(result) else 0 + return result / peak * 0.999 if peak >= 1 else result + + +def prepare_dataset(item: dict, clip_seconds: float, silence_db: float, + log: Callable[[str], None]) -> Path: + files = item["recordings"] + if not files: + raise ValueError("Add WAV, FLAC, or OGG recordings to this character first.") + broken = [entry["name"] for entry in files if entry["error"]] + if broken: + raise ValueError(f"Unreadable recordings: {', '.join(broken)}") + run_id = datetime.now().strftime("%Y%m%d-%H%M%S") + "-" + uuid.uuid4().hex[:8] + output = WORKSPACE / item["id"] / "datasets" / run_id + ace_dir, svc_dir = output / "ace_audio", output / "svc_audio" + ace_dir.mkdir(parents=True) + svc_dir.mkdir() + samples, provenance, warnings = [], [], [] + for entry in files: + log(f"Reading {entry['name']}") + audio, rate = sf.read(entry["path"], dtype="float32", always_2d=True) + if not len(audio) or audio.shape[1] > 2 or not np.isfinite(audio).all(): + raise ValueError(f"{entry['name']}: expected finite mono/stereo audio.") + clipping = float(np.mean(np.abs(audio) >= 0.999)) + if clipping > 0.001: + warnings.append(f"{entry['name']}: {clipping:.1%} of samples near full scale; review clipping.") + ranges = segment_ranges(audio, rate, clip_seconds, silence_db) + if not ranges: + warnings.append(f"{entry['name']}: no vocal-length regions above threshold.") + for start, end in ranges: + clip = audio[start:end] + mono = clip.mean(axis=1) + channel_energy = np.mean(np.square(clip, dtype=np.float64), axis=0) + if float(np.mean(np.square(mono, dtype=np.float64))) < float(channel_energy.max()) * 0.25: + mono = clip[:, int(np.argmax(channel_energy))] + warnings.append(f"{entry['name']}: SVC downmix used the strongest channel to avoid cancellation.") + name = f"{len(samples) + 1:05d}.wav" + stereo = np.repeat(clip, 2, axis=1) if clip.shape[1] == 1 else clip + sf.write(str(ace_dir / name), converted_audio(stereo, rate, 48000), 48000, subtype="PCM_16") + sf.write(str(svc_dir / name), converted_audio(mono, rate, 40000), 40000, subtype="PCM_16") + samples.append({ + "id": name[:-4], "filename": name, "audio_path": str((ace_dir / name).resolve()), + "caption": item["caption"], "lyrics": "", "raw_lyrics": "", + "duration": round((end - start) / rate, 3), "language": item["language"], + "is_instrumental": False, "custom_tag": item["trigger"], "labeled": False, + "reviewed": False, "bpm": None, "keyscale": "", "timesignature": "", + }) + provenance.append({ + "filename": name, "source": entry["path"], + "start_seconds": round(start / rate, 6), "end_seconds": round(end / rate, 6), + }) + log(f" {len(ranges)} clips retained") + if not samples: + raise ValueError("No usable clips. Check the audio and silence threshold; source files were not changed.") + path = output / "dataset.json" + write_json(path, { + "metadata": { + "name": item["name"], "custom_tag": item["trigger"], "tag_position": "prepend", + "created_at": now(), "num_samples": len(samples), "all_instrumental": False, + "genre_ratio": 0, + }, + "samples": samples, "warnings": warnings, + }) + write_json(output / "segments.json", { + "clip_seconds": clip_seconds, "silence_db": silence_db, "sources": provenance, + }) + item["dataset"] = str(path.relative_to(WORKSPACE / item["id"])) + save_character(item) + log(f"Prepared {len(samples)} clips. Lyrics and listening review are still required for ACE-Step.") + for warning in warnings: + log("WARNING: " + warning) + return path + + +def require_review(path: Path) -> dict: + data = read_json(path) + samples = data.get("samples", []) + if not samples: + raise ValueError("The dataset is empty.") + incomplete = [ + s["filename"] for s in samples + if not s.get("reviewed") or not s.get("caption", "").strip() or not s.get("lyrics", "").strip() + or s.get("is_instrumental", True) + ] + if incomplete: + raise ValueError( + f"Review and annotate {len(incomplete)} clips before ACE-Step preprocessing: " + + ", ".join(incomplete[:8]) + + ". For wordless singing, describe the actual vocalisation; do not label vocals instrumental." + ) + return data + + +def backend_paths(model: str) -> tuple[Path, Path]: + if model not in MODELS: + raise ValueError("Choose an ACE-Step XL model.") + config = settings() + root, python = Path(config["ace_root"]), Path(config["ace_python"]) + for path in (python, root / "train.py", root / "checkpoints" / model / "config.json"): + if not path.is_file(): + raise FileNotFoundError(f"Required ACE-Step file not found: {path}") + return root, python + + +def training_command(item: dict, options: dict, tensor_dir: Path, output: Path) -> list[str]: + model = options["model"] + root, python = backend_paths(model) + turbo = MODELS[model] == "xl_turbo" + return [ + str(python), "-u", str(root / "train.py"), "--plain", "--yes", "fixed", + "--checkpoint-dir", str(root / "checkpoints"), + # Literal folder names also work with older upstream XL path validators. + "--model-variant", model, "--base-model", MODELS[model], + "--dataset-dir", str(tensor_dir), "--output-dir", str(output), + "--device", "cuda", "--precision", "bf16", "--num-workers", "0", + "--batch-size", "1", "--gradient-accumulation", str(options["accumulation"]), + "--epochs", str(options["epochs"]), "--lr", str(options["learning_rate"]), + "--rank", str(options["rank"]), "--alpha", str(options["rank"] * 2), + "--save-every", str(min(10, options["epochs"])), "--warmup-steps", "10", + "--gradient-checkpointing", "--offload-encoder", "--optimizer-type", "adamw", + "--shift", "3.0" if turbo else "1.0", "--num-inference-steps", "8" if turbo else "50", + ] + + +def export_svc(item: dict, log: Callable[[str], None]) -> Path: + dataset = dataset_path(item) + data = read_json(dataset) + files = sorted((dataset.parent / "svc_audio").glob("*.wav")) + if not files or len(files) != len(data["samples"]): + raise ValueError("SVC audio is incomplete. Prepare a new dataset.") + target = dataset.parent / f"{slug(item['name'])}-svc-dataset.zip" + with zipfile.ZipFile(target, "w", compression=zipfile.ZIP_STORED) as archive: + for path in files: + archive.write(path, arcname=f"{slug(item['name'])}/{path.name}") + archive.writestr("TRAINING.txt", ( + f"Character: {item['name']}\n" + "Dataset: mono 40 kHz PCM-16 WAV; not a trained conversion model.\n\n" + "Recommended separate SVC backend: Applio (RVC).\n" + "https://github.com/IAHispano/Applio\n\n" + "Extract the character folder. In Applio's Train tab, choose a unique model name,\n" + "point the dataset field to the extracted folder, and choose 40 kHz.\n" + "Preprocess, extract pitch/features (RMVPE is a common singing choice),\n" + "then train and build the retrieval index. Review its current training guide\n" + "and install its required base assets in its own environment.\n" + "Use the resulting .pth and .index together for conversion of isolated vocals.\n" + "Preserve pitch unless a deliberate transpose is wanted; mix vocals back into\n" + "the original instrumental. Do not feed a full mix into a vocal-only converter.\n\n" + "An ACE-Step LoRA is not an RVC model. Do not rename adapter files to .pth.\n" + "Train only voices you are authorized to use. Listen to every clip first.\n" + )) + log(f"SVC dataset exported: {target}. Train .pth / .index separately in Applio.") + return target + + +class JobManager: + def __init__(self) -> None: + self.lock = threading.RLock() + self.jobs: list[dict] = [] + self.busy = False + self.process: subprocess.Popen | None = None + self.closing = False + + def load_history(self) -> None: + with self.lock: + paths = sorted(WORKSPACE.glob("*/jobs/*/job.json"), reverse=True) + loaded = [read_json(path) for path in paths] + self.jobs = sorted(loaded, key=lambda job: job["started_at"])[-30:] + for job in self.jobs: + if job["status"] in {"queued", "running"}: + job.update(status="failed", error="Studio stopped before this job completed.", + ended_at=now()) + self.persist(job) + + def ensure_idle(self) -> None: + if self.busy: + raise ValueError("A job is running. Wait for it to finish before changing the workspace.") + + def start(self, cid: str, action: str, options: dict) -> dict: + with self.lock: + self.ensure_idle() + if self.closing: + raise ValueError("The studio is shutting down.") + item = character(cid) + if action in {"preprocess", "train"} and not options["authorized"]: + raise ValueError("Confirm that you are authorized to train this voice.") + job_id = datetime.now().strftime("%Y%m%d-%H%M%S") + "-" + uuid.uuid4().hex[:8] + job = { + "id": job_id, "character_id": cid, "character_name": item["name"], + "action": action, "status": "queued", "started_at": now(), "ended_at": None, + "error": None, "log": [], "artifacts": [], + "options": {key: value for key, value in options.items() if key != "authorized"}, + "authorization_confirmed": bool(options["authorized"]), + } + self.jobs.append(job) + self.busy = True + self.persist(job) + thread = threading.Thread(target=self.run, args=(job, item, options), daemon=True) + thread.start() + return dict(job) + + def persist(self, job: dict) -> None: + write_json(WORKSPACE / job["character_id"] / "jobs" / job["id"] / "job.json", job) + + def log(self, job: dict, message: str) -> None: + with self.lock: + line = re.sub(r"\x1b\[[0-9;]*[A-Za-z]", "", message.rstrip()) + job["log"].append(line) + job["log"] = job["log"][-400:] + path = WORKSPACE / job["character_id"] / "jobs" / job["id"] / "output.log" + with path.open("a", encoding="utf-8") as handle: + handle.write(line + "\n") + + def run_process(self, job: dict, command: list[str], cwd: Path) -> None: + self.log(job, subprocess.list2cmdline(command)) + environment = {**os.environ, "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1"} + with self.lock: + if self.closing: + raise RuntimeError("Studio shutdown interrupted the job.") + process = subprocess.Popen( + command, cwd=str(cwd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + text=True, encoding="utf-8", errors="replace", env=environment, + ) + self.process = process + try: + assert process.stdout is not None + reported_failure = False + for line in process.stdout: + self.log(job, line) + if "[FAIL]" in line: + reported_failure = True + code = process.wait() + if code: + raise RuntimeError(f"Backend exited with code {code}. See the full job log.") + if reported_failure: + raise RuntimeError("Backend reported a failure despite exiting with code 0. See the full job log.") + finally: + with self.lock: + self.process = None + + def run(self, job: dict, item: dict, options: dict) -> None: + log = lambda message: self.log(job, message) + try: + with self.lock: + job["status"] = "running" + self.persist(job) + log(f"{job['action'].upper()} | {item['name']} | {now()}") + action = job["action"] + if action == "prepare": + prepare_dataset(item, options["clip_seconds"], options["silence_db"], log) + elif action == "export_svc": + job["artifacts"].append(str(export_svc(item, log).relative_to(WORKSPACE))) + else: + path = dataset_path(item) + data = require_review(path) + model = options["model"] + root, python = backend_paths(model) + if action == "preprocess": + tensor_dir = path.parent / "tensors" / job["id"] + command = [ + str(python), "-u", str(Path(__file__).with_name("ace_worker.py")), + "--ace-root", str(root), "--dataset", str(path), "--output", str(tensor_dir), + "--model", model, + ] + self.run_process(job, command, root) + count = sum(not p.name.endswith(".tmp.pt") for p in tensor_dir.glob("*.pt")) + if count != len(data["samples"]): + raise RuntimeError(f"Expected {len(data['samples'])} tensors, found {count}.") + write_json(path.parent / "ready.json", { + "dataset_sha256": fingerprint(path), "model": model, + "tensor_dir": str(tensor_dir), "count": count, "created_at": now(), + }) + log(f"All {count} clips preprocessed for {model}.") + elif action == "train": + ready_path = path.parent / "ready.json" + if not ready_path.is_file(): + raise ValueError("Preprocess this dataset before training.") + ready = read_json(ready_path) + if ready["dataset_sha256"] != fingerprint(path) or ready["model"] != model: + raise ValueError("Dataset or model changed. Preprocess again before training.") + tensor_dir = Path(ready["tensor_dir"]) + if sum(not p.name.endswith(".tmp.pt") for p in tensor_dir.glob("*.pt")) != len(data["samples"]): + raise ValueError("Preprocessed tensors are incomplete. Preprocess again.") + output = WORKSPACE / item["id"] / "jobs" / job["id"] / "adapter" + command = training_command(item, options, tensor_dir, output) + write_json(output.parent / "recipe.json", { + "character": item["name"], "trigger": data["metadata"]["custom_tag"], "base_model": model, + "dataset_sha256": fingerprint(path), "command": command, + "authorization_confirmed_at": job["started_at"], + }) + self.run_process(job, command, root) + final = output / "final" + weights = sorted(final.rglob("*.safetensors")) + if not weights or not (final / "adapter_config.json").is_file(): + raise RuntimeError("Backend did not produce a complete final adapter. Inspect the job log.") + job["artifacts"] = [str(p.relative_to(WORKSPACE)) for p in weights] + log("Adapter files found. Audition checkpoints in the same XL base model before choosing one.") + else: + raise ValueError("Unknown job action.") + with self.lock: + job["status"] = "completed" + except Exception as exc: + self.log(job, traceback.format_exc()) + with self.lock: + job["status"], job["error"] = "failed", str(exc) + finally: + with self.lock: + job["ended_at"] = now() + self.busy = False + self.persist(job) + + def snapshot(self) -> list[dict]: + with self.lock: + return [json.loads(json.dumps(job)) for job in reversed(self.jobs[-30:])] + + def shutdown(self) -> None: + with self.lock: + self.closing = True + process = self.process + if process and process.poll() is None: + process.terminate() + try: + process.wait(timeout=10) + except subprocess.TimeoutExpired: + process.kill() + process.wait() + + +jobs = JobManager()