Copying More Repo to Demo
This commit is contained in:
parent
8785dcf45d
commit
cb66dcb8e3
|
|
@ -0,0 +1,5 @@
|
||||||
|
workspace/
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
.venv/
|
||||||
|
.env
|
||||||
|
|
@ -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 <http://127.0.0.1:9874>. 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-id>\
|
||||||
|
character.json
|
||||||
|
datasets\
|
||||||
|
<version>\
|
||||||
|
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-id>\
|
||||||
|
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)
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
"""Local voice-character dataset and training studio."""
|
||||||
|
|
@ -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()
|
||||||
|
|
@ -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()
|
||||||
|
|
@ -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) => `<svg class="icon" aria-hidden="true"><use href="#i-${name}"/></svg>`;
|
||||||
|
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) => `<div class="empty-state">${escapeHTML(text)}</div>`;
|
||||||
|
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) =>
|
||||||
|
`<option value="${escapeHTML(model.id)}">${escapeHTML(model.label)}${model.available ? "" : " - not installed"}</option>`,
|
||||||
|
).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) => `
|
||||||
|
<button class="character-item ${character.id === state.cid ? "selected" : ""}" data-character="${character.id}">
|
||||||
|
<span class="avatar">${escapeHTML(initials(character.name))}</span>
|
||||||
|
<span class="character-text"><strong>${escapeHTML(character.name)}</strong>
|
||||||
|
<small>${character.recordings.length} recordings · ${duration(character.duration)}</small></span>
|
||||||
|
</button>`).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) => `
|
||||||
|
<button class="library-card" data-character="${character.id}">
|
||||||
|
<span class="avatar">${escapeHTML(initials(character.name))}</span>
|
||||||
|
<span><h3>${escapeHTML(character.name)}</h3><p>${character.recordings.length} recordings · ${duration(character.duration)}</p></span>
|
||||||
|
${icon("arrow")}
|
||||||
|
</button>`).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) => `
|
||||||
|
<div class="source-row"><span class="file-icon">${icon("wave")}</span>
|
||||||
|
<div class="source-details"><strong>${escapeHTML(recording.name)}</strong>
|
||||||
|
<small>${recording.error ? escapeHTML(recording.error) : `${duration(recording.duration)} · ${recording.sample_rate / 1000} kHz · ${recording.channels === 2 ? "Stereo" : "Mono"} · ${escapeHTML(recording.subtype)}`}</small></div>
|
||||||
|
${recording.error ? "" : `<audio controls preload="none" aria-label="${escapeHTML(recording.name)}" src="/api/characters/${item.id}/recordings/${recording.id}"></audio>`}
|
||||||
|
</div>`).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) => `
|
||||||
|
<button class="clip-item ${sample.id === state.sample ? "selected" : ""} ${sample.reviewed ? "reviewed" : ""}" data-sample="${escapeHTML(sample.id)}">
|
||||||
|
${icon(sample.reviewed ? "check" : "play")}<strong>${escapeHTML(sample.filename)}</strong>
|
||||||
|
<small>${sample.duration.toFixed(1)} s ${sample.reviewed ? "· reviewed" : ""}</small>
|
||||||
|
</button>`).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) => `
|
||||||
|
<div class="artifact-row"><span class="stat-icon ${artifact.name.endsWith(".zip") ? "mint" : "lavender"}">${icon("box")}</span>
|
||||||
|
<div class="artifact-detail"><strong>${escapeHTML(artifact.name)}</strong>
|
||||||
|
<small>${escapeHTML(artifact.relative)}</small></div>
|
||||||
|
<span class="artifact-size">${size(artifact.bytes)}</span>
|
||||||
|
<a class="button secondary" href="${downloadURL(artifact.relative)}" download>Download</a>
|
||||||
|
</div>`).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) => `
|
||||||
|
<li class="${complete ? "complete" : ""}"><span class="check-circle">${complete ? icon("check") : index + 1}</span>${escapeHTML(text)}</li>`,
|
||||||
|
).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) => `
|
||||||
|
<option value="${escapeHTML(job.id)}"${job.id === state.jobId ? " selected" : ""}>${escapeHTML(labels[job.action] || job.action)} - ${escapeHTML(job.status)}</option>`,
|
||||||
|
).join("") || '<option value="">No jobs yet</option>';
|
||||||
|
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);
|
||||||
|
|
@ -0,0 +1,139 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<meta name="theme-color" content="#f5f4f9">
|
||||||
|
<title>Voice Studio - Character Training</title>
|
||||||
|
<link rel="stylesheet" href="/static/styles.css">
|
||||||
|
<script defer src="/static/app.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<svg class="icon-library" aria-hidden="true" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<symbol id="i-wave" viewBox="0 0 24 24"><path d="M3 10v4m4-9v14m5-17v20m5-17v14m4-9v4"/></symbol>
|
||||||
|
<symbol id="i-grid" viewBox="0 0 24 24"><rect x="3" y="3" width="7" height="7" rx="2"/><rect x="14" y="3" width="7" height="7" rx="2"/><rect x="3" y="14" width="7" height="7" rx="2"/><rect x="14" y="14" width="7" height="7" rx="2"/></symbol>
|
||||||
|
<symbol id="i-mic" viewBox="0 0 24 24"><rect x="9" y="2" width="6" height="13" rx="3"/><path d="M5 10v2a7 7 0 0 0 14 0v-2M12 19v3m-4 0h8"/></symbol>
|
||||||
|
<symbol id="i-spark" viewBox="0 0 24 24"><path d="m12 3 2.5 6.5L21 12l-6.5 2.5L12 21l-2.5-6.5L3 12l6.5-2.5L12 3Z"/></symbol>
|
||||||
|
<symbol id="i-box" viewBox="0 0 24 24"><path d="m12 3 9 5v9l-9 5-9-5V8l9-5Zm0 9 9-4M12 12 3 8m9 4v10"/></symbol>
|
||||||
|
<symbol id="i-settings" viewBox="0 0 24 24"><path d="M4 7h16M4 17h16"/><circle cx="8" cy="7" r="3"/><circle cx="16" cy="17" r="3"/></symbol>
|
||||||
|
<symbol id="i-plus" viewBox="0 0 24 24"><path d="M12 5v14M5 12h14"/></symbol>
|
||||||
|
<symbol id="i-arrow" viewBox="0 0 24 24"><path d="M5 12h14m-6-6 6 6-6 6"/></symbol>
|
||||||
|
<symbol id="i-upload" viewBox="0 0 24 24"><path d="M12 16V3m-5 5 5-5 5 5M4 16v5h16v-5"/></symbol>
|
||||||
|
<symbol id="i-check" viewBox="0 0 24 24"><path d="m5 12 4 4L19 6"/></symbol>
|
||||||
|
<symbol id="i-play" viewBox="0 0 24 24"><path d="m8 4 12 8-12 8V4Z"/></symbol>
|
||||||
|
<symbol id="i-folder" viewBox="0 0 24 24"><path d="M3 7V4h6l3 3h9v13H3V7Z"/></symbol>
|
||||||
|
</svg>
|
||||||
|
|
||||||
|
<aside class="sidebar">
|
||||||
|
<a class="brand" href="#overview" aria-label="Voice Studio home">
|
||||||
|
<span class="brand-mark"><svg class="icon"><use href="#i-wave"/></svg></span>
|
||||||
|
<span>voice<span class="brand-light">studio</span><small>CHARACTER TRAINING</small></span>
|
||||||
|
</a>
|
||||||
|
<div class="workspace-label">WORKSPACE <span class="local-dot">LOCAL</span></div>
|
||||||
|
<nav class="navigation" aria-label="Main navigation">
|
||||||
|
<button class="nav-item active" data-page="overview"><svg class="icon"><use href="#i-grid"/></svg>Overview</button>
|
||||||
|
<button class="nav-item" data-page="recordings"><svg class="icon"><use href="#i-mic"/></svg>Dataset & recordings<span id="nav-count" class="nav-count">0</span></button>
|
||||||
|
<button class="nav-item" data-page="training"><svg class="icon"><use href="#i-spark"/></svg>Train a voice</button>
|
||||||
|
<button class="nav-item" data-page="exports"><svg class="icon"><use href="#i-box"/></svg>Models & exports</button>
|
||||||
|
</nav>
|
||||||
|
<div class="library-label"><span>YOUR CHARACTERS</span><button class="icon-button add-character" title="Add a voice character" aria-label="Add a voice character"><svg class="icon"><use href="#i-plus"/></svg></button></div>
|
||||||
|
<div id="character-list" class="character-list" aria-label="Voice characters"></div>
|
||||||
|
<button class="sidebar-add add-character"><svg class="icon"><use href="#i-plus"/></svg>New character</button>
|
||||||
|
<div class="sidebar-bottom">
|
||||||
|
<div class="privacy-card"><span class="privacy-icon"><svg class="icon"><use href="#i-folder"/></svg></span><div><strong>Your voice. Your machine.</strong><p>Audio stays on your computer.</p></div></div>
|
||||||
|
<button class="nav-item" data-page="settings"><svg class="icon"><use href="#i-settings"/></svg>Workspace settings</button>
|
||||||
|
<div class="sidebar-version">VOICE STUDIO <span>ACE-STEP 1.5 XL</span></div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<div class="main-shell">
|
||||||
|
<header class="topbar">
|
||||||
|
<div class="breadcrumb">Workspace <span>/</span> <strong id="breadcrumb-name">Voice library</strong></div>
|
||||||
|
<div class="topbar-right"><span id="backend-indicator" class="connection"><i></i>Checking workspace</span><span class="avatar mini">VS</span></div>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
<div id="connection-error" class="notice danger hidden" role="alert"></div>
|
||||||
|
<section id="page-overview" class="page">
|
||||||
|
<div class="page-heading"><div><p class="eyebrow">THE VOICE BEHIND THE MUSIC</p><h1>Your next voice starts here.</h1><p class="muted">Build a character. Shape its sound. Make it your own.</p></div><button class="button primary add-character"><svg class="icon"><use href="#i-plus"/></svg>New character</button></div>
|
||||||
|
<div class="hero">
|
||||||
|
<div class="hero-content"><span class="pill hero-pill">VOICE CHARACTER WORKSPACE</span><h2 id="hero-name">A place for every voice.</h2><p>From your recordings to a recognisable vocal identity.<br>One library, two distinct training paths.</p><div class="hero-actions"><button class="button white" data-page="recordings">Prepare your dataset<svg class="icon"><use href="#i-arrow"/></svg></button><button class="button ghost-light" data-page="training">Explore training</button></div></div>
|
||||||
|
<div class="voice-art" aria-hidden="true"><div class="orbit orbit-one"></div><div class="orbit orbit-two"></div><div class="orbit orbit-three"></div><div class="voice-core"><svg><use href="#i-wave"/></svg></div><span class="art-label">CRAFTED FROM YOUR SOUND</span></div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-grid">
|
||||||
|
<article class="stat"><span class="stat-icon lavender"><svg class="icon"><use href="#i-mic"/></svg></span><div><span class="stat-label">Source recordings</span><strong id="stat-recordings">0</strong><small>Original files preserved</small></div></article>
|
||||||
|
<article class="stat"><span class="stat-icon peach"><svg class="icon"><use href="#i-wave"/></svg></span><div><span class="stat-label">Source audio</span><strong id="stat-duration">0:00</strong><small>In this character's library</small></div></article>
|
||||||
|
<article class="stat"><span class="stat-icon mint"><svg class="icon"><use href="#i-check"/></svg></span><div><span class="stat-label">Reviewed clips</span><strong id="stat-clips">0 / 0</strong><small>Listening & annotation</small></div></article>
|
||||||
|
<article class="stat"><span class="stat-icon blue"><svg class="icon"><use href="#i-box"/></svg></span><div><span class="stat-label">Adapter weight files</span><strong id="stat-models">0</strong><small>Actual saved artifacts</small></div></article>
|
||||||
|
</div>
|
||||||
|
<div class="section-heading"><div><h2>A clear path to your character</h2><p class="muted">No hidden steps. No automatic training.</p></div><button class="text-button" data-page="training">Open training<svg class="icon"><use href="#i-arrow"/></svg></button></div>
|
||||||
|
<div class="workflow-grid">
|
||||||
|
<article class="step-card"><span class="step-number">01</span><span id="stage-source" class="pill">ADD RECORDINGS</span><h3>Start with a clean voice</h3><p>Add isolated vocal takes. Keep accompaniment, heavy reverb, and other singers out of the training set.</p><button class="text-button" data-page="recordings">Manage recordings<svg class="icon"><use href="#i-arrow"/></svg></button></article>
|
||||||
|
<article class="step-card"><span class="step-number">02</span><span id="stage-review" class="pill">PREPARE & REVIEW</span><h3>Give the details a listen</h3><p>Create short clips, check each one, and add accurate lyrics or wordless-vocal descriptions for ACE-Step.</p><button class="text-button" data-page="recordings">Review your clips<svg class="icon"><use href="#i-arrow"/></svg></button></article>
|
||||||
|
<article class="step-card"><span class="step-number">03</span><span id="stage-train" class="pill">TRAIN WHEN READY</span><h3>Make the character yours</h3><p>Train an XL adapter for new songs, or export a dataset for a separate RVC voice-conversion model.</p><button class="text-button" data-page="exports">See output formats<svg class="icon"><use href="#i-arrow"/></svg></button></article>
|
||||||
|
</div>
|
||||||
|
<div class="section-heading"><div><h2>Your character library</h2><p class="muted">Each voice has its own data, training history, and exports.</p></div><span id="library-total" class="pill">0 CHARACTERS</span></div>
|
||||||
|
<div id="library-grid" class="library-grid"></div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="page-recordings" class="page hidden">
|
||||||
|
<div class="page-heading"><div><p class="eyebrow">GOOD MODELS START WITH GOOD DATA</p><h1>Dataset & recordings</h1><p class="muted">Originals stay untouched. Every prepared clip keeps its source timestamps.</p></div><button id="upload-button" class="button primary requires-character"><svg class="icon"><use href="#i-upload"/></svg>Add recordings</button><input id="upload-input" type="file" accept=".wav,.flac,.ogg" multiple hidden></div>
|
||||||
|
<div class="notice"><strong>Listen first.</strong> These tools split and resample audio; they do not remove accompaniment, infer permission, or verify that a recording is an isolated vocal.</div>
|
||||||
|
<details class="panel profile-panel"><summary>Character identity & dataset defaults</summary><form id="profile-form" class="form-grid"><label>Display name<input id="profile-name" required maxlength="80"></label><label>Voice trigger<input id="profile-trigger" required maxlength="64"></label><label>Vocal language<input id="profile-language" placeholder="en, unknown..." required></label><label class="span-two">Default clip caption<input id="profile-caption" required placeholder="Describe the actual vocal sound"></label><div class="align-end"><button class="button secondary requires-character" type="submit">Save identity</button></div><p class="field-help span-all">Defaults apply to the next dataset. Existing clip annotations are kept as-is.</p></form></details>
|
||||||
|
<div class="dataset-grid">
|
||||||
|
<article class="panel"><div class="panel-heading"><h2>Source library</h2><span id="source-count" class="pill">0 FILES</span></div><div id="source-list" class="source-list"></div><p id="source-path" class="path-text"></p></article>
|
||||||
|
<article class="panel prep-panel"><span class="eyebrow">NON-DESTRUCTIVE PREPARATION</span><h2>A little structure.<br>A better starting point.</h2><p class="muted">Silence-aware splitting, 48 kHz stereo for ACE-Step, and 40 kHz mono for SVC.</p><div class="form-grid"><label>Maximum clip length<select id="clip-seconds"><option value="8">8 seconds</option><option value="12" selected>12 seconds</option><option value="20">20 seconds</option><option value="30">30 seconds</option></select></label><label>Silence threshold<select id="silence-db"><option value="-55">-55 dB</option><option value="-45" selected>-45 dB</option><option value="-35">-35 dB</option></select></label></div><button id="prepare-button" class="button primary full requires-character"><svg class="icon"><use href="#i-wave"/></svg>Prepare a new dataset</button><p class="field-help">Creates a new version; it never overwrites an earlier dataset.</p></article>
|
||||||
|
</div>
|
||||||
|
<div class="section-heading"><div><h2>Clip review</h2><p class="muted">Select a clip, listen, and annotate what is actually sung.</p></div><span id="review-count" class="pill">NO DATASET YET</span></div>
|
||||||
|
<div id="dataset-warnings" class="notice warning hidden"></div>
|
||||||
|
<div class="review-grid">
|
||||||
|
<article class="panel clip-panel"><div id="clip-list" class="clip-list"></div></article>
|
||||||
|
<article class="panel annotation-panel"><div class="panel-heading"><h2 id="clip-heading">Choose a clip</h2><span id="clip-duration" class="pill">--</span></div><audio id="clip-audio" controls preload="none"></audio><form id="annotation-form"><label>Caption<textarea id="clip-caption" rows="2" required placeholder="Describe the audible voice and performance."></textarea></label><label>Lyrics / actual vocalisation<textarea id="clip-lyrics" rows="5" placeholder="Accurate syllables or lyrics. For wordless singing, describe the actual vocalisation."></textarea></label><p class="field-help">Never use [Instrumental] for vocal recordings. Unknown lyrics are left blank, not invented.</p><label class="check-label"><input id="clip-reviewed" type="checkbox"><span>I listened to this clip and verified its caption and vocal text.</span></label><div class="button-row"><button id="save-clip" class="button primary" type="submit" disabled>Save clip review</button><button id="next-clip" class="button secondary" type="button" disabled>Next clip<svg class="icon"><use href="#i-arrow"/></svg></button></div></form></article>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="page-training" class="page hidden">
|
||||||
|
<div class="page-heading"><div><p class="eyebrow">A VOICE WITH YOUR SIGNATURE</p><h1>Train your character</h1><p class="muted">An ACE-Step XL adapter for original songs. Your configuration, your checkpoints.</p></div><span class="pill accent">LOCAL GPU WORKFLOW</span></div>
|
||||||
|
<div class="notice warning"><strong>Two different models.</strong> This trainer creates an ACE-Step adapter. For SVC that preserves an existing performance, export the vocal dataset and train a separate RVC model in Applio.</div>
|
||||||
|
<div class="training-grid">
|
||||||
|
<article class="panel"><div class="panel-heading"><h2>Training recipe</h2><span class="pill">XL / 4B</span></div><form id="training-form">
|
||||||
|
<label>Base model<select id="model-select"><option value="acestep-v15-xl-sft">XL SFT</option><option value="acestep-v15-xl-turbo">XL Turbo</option><option value="acestep-v15-xl-base">XL Base</option></select></label>
|
||||||
|
<p class="field-help">Keep the adapter paired with the exact XL variant used for training.</p>
|
||||||
|
<div class="form-grid"><label>Epochs<input id="epochs" type="number" min="1" max="2000" value="100" required></label><label>LoRA rank<select id="rank"><option>8</option><option selected>16</option><option>32</option><option>64</option></select></label><label>Learning rate<input id="learning-rate" type="number" min="0.000001" max="0.001" step="0.000001" value="0.0001" required></label><label>Gradient accumulation<input id="accumulation" type="number" min="1" max="32" value="4" required></label></div>
|
||||||
|
<div class="recipe-footnote"><svg class="icon"><use href="#i-settings"/></svg><span>Batch 1 · BF16 · Gradient checkpointing<br>Encoder offload · AdamW · Windows-safe workers</span></div>
|
||||||
|
<label class="check-label authorization"><input id="authorized" type="checkbox"><span>I own or have permission to train and use this voice. I have checked that the clips are suitable isolated vocals.</span></label>
|
||||||
|
<div class="button-row"><button id="preprocess-button" class="button secondary requires-character" type="button">1. Preprocess clips</button><button id="train-button" class="button primary requires-character" type="submit"><svg class="icon"><use href="#i-spark"/></svg>2. Start training</button></div>
|
||||||
|
<p class="field-help">These buttons start real backend jobs. All clips require review before preprocessing. No training has run just by opening this page.</p>
|
||||||
|
</form></article>
|
||||||
|
<div class="training-aside">
|
||||||
|
<article class="panel readiness"><div class="panel-heading"><h2>Before you begin</h2><span id="readiness-pill" class="pill">CHECKLIST</span></div><ul id="readiness-list" class="checklist"></ul><p class="field-help">Short clips and batch size 1 are conservative starting settings, not a guarantee that XL training fits in VRAM. Close other GPU workloads before training.</p></article>
|
||||||
|
<article class="panel command-panel"><div class="panel-heading"><h2>Under the hood</h2><button id="preview-recipe" class="text-button requires-character">Preview command</button></div><pre id="command-preview">Your command preview will appear here.
|
||||||
|
Previewing does not execute anything.</pre></article>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<article class="log-panel"><div class="log-toolbar"><div><span id="job-dot" class="status-dot"></span><strong id="job-title">Training console</strong><span id="job-status" class="pill">IDLE</span></div><select id="job-select" aria-label="Choose a job"><option value="">No jobs yet</option></select></div><pre id="job-log" tabindex="0" aria-label="Job output">Ready when you are.
|
||||||
|
No jobs have been started for this character.</pre><div class="log-footer"><span>Output comes directly from your local jobs.</span><span id="job-time">No elapsed time to report</span></div></article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="page-exports" class="page hidden">
|
||||||
|
<div class="page-heading"><div><p class="eyebrow">TAKE YOUR CHARACTER INTO THE MUSIC</p><h1>Models & exports</h1><p class="muted">The right artifact for the right workflow. No interchangeable-file assumptions.</p></div></div>
|
||||||
|
<div class="export-grid">
|
||||||
|
<article class="panel export-card"><span class="export-icon lavender"><svg class="icon"><use href="#i-spark"/></svg></span><span class="eyebrow">ORIGINAL SONGS</span><h2>ACE-Step XL adapter</h2><p>Use trained weights with the matching XL base model in ACE-Step's browser UI. Include your character's trigger in the generation caption.</p><div class="format-tags"><span>.safetensors</span><span>adapter_config.json</span></div><div class="export-note"><strong id="export-trigger">No character selected</strong><small>Character trigger</small></div><button class="button secondary full" data-page="training">Go to XL training<svg class="icon"><use href="#i-arrow"/></svg></button><p class="field-help">ComfyUI support depends on your loader's XL and adapter-format support. The studio does not silently convert or merge weights.</p></article>
|
||||||
|
<article class="panel export-card"><span class="export-icon mint"><svg class="icon"><use href="#i-mic"/></svg></span><span class="eyebrow">SINGING VOICE CONVERSION</span><h2>RVC / Applio dataset</h2><p>Preserve a sung performance while changing its vocal identity. Export prepared clips, then train the separate conversion model in Applio.</p><div class="format-tags"><span>40 kHz mono WAV</span><span>.zip dataset</span></div><div class="export-note"><strong>Separate model training required</strong><small>Applio produces .pth + .index files</small></div><button id="export-svc" class="button primary full requires-character"><svg class="icon"><use href="#i-box"/></svg>Build SVC dataset export</button><p class="field-help">This is a dataset export, not a trained SVC model. Use isolated vocals for training and conversion; remix with the instrumental afterwards.</p></article>
|
||||||
|
</div>
|
||||||
|
<div class="section-heading"><div><h2>Saved artifacts</h2><p class="muted">Files that actually exist in this character's workspace.</p></div><button id="refresh-artifacts" class="text-button requires-character">Refresh files</button></div>
|
||||||
|
<div id="artifact-list" class="panel artifact-list"></div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section id="page-settings" class="page hidden">
|
||||||
|
<div class="page-heading"><div><p class="eyebrow">BUILT AROUND YOUR LOCAL SETUP</p><h1>Workspace settings</h1><p class="muted">Point the studio at your existing installation. No containers or MCP server required.</p></div></div>
|
||||||
|
<article class="panel settings-panel"><form id="settings-form"><label>ACE-Step installation<input id="settings-ace" required spellcheck="false"></label><label>ACE-Step Python interpreter<input id="settings-python" required spellcheck="false"></label><p class="field-help">Use its prepared environment, not a second conflicting Torch installation.</p><label>Voice character library<input id="settings-source" required spellcheck="false"></label><p class="field-help">Each immediate subfolder is a separate character. Add as many characters as you need.</p><label>Studio output workspace<input id="settings-workspace" readonly></label><p class="field-help">Set VOICE_STUDIO_WORKSPACE before launch to change the output location.</p><button class="button primary" type="submit">Save workspace settings</button></form></article>
|
||||||
|
<article class="panel setup-notes"><h2>What runs where</h2><div class="setup-grid"><div><h3>Voice Studio</h3><p>A loopback-only browser UI, local dataset tools, and job orchestration. It never starts training automatically.</p></div><div><h3>ACE-Step 1.5</h3><p>The existing XL models and native Side-Step training code. Preprocessing and training run in its Python environment.</p></div><div><h3>Applio / RVC</h3><p>A separate conversion trainer. Import the SVC dataset there; its runtime, pretrained assets, and models stay separate.</p></div></div></article>
|
||||||
|
</section>
|
||||||
|
<footer class="main-footer"><span>VOICE STUDIO <span class="footer-dot">·</span> Made for the voice behind the song.</span><span>Local files. Explicit actions. Your control.</span></footer>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<dialog id="character-dialog"><form id="character-form"><div class="dialog-heading"><span class="stat-icon lavender"><svg class="icon"><use href="#i-mic"/></svg></span><button class="icon-button" type="button" id="close-dialog" aria-label="Close dialog">×</button></div><p class="eyebrow">EVERY VOICE HAS A STORY</p><h2>Meet your next character.</h2><p class="muted">Give this voice its own place in your library. Add recordings when you're ready.</p><label>Character name<input id="new-name" required maxlength="80" placeholder="e.g. Ember, Midnight Alto, Folk Tenor"></label><label>Voice trigger <span class="optional">optional</span><input id="new-trigger" maxlength="64" placeholder="e.g. ember_voice"></label><p class="field-help">A unique tag to use in ACE-Step generation captions. Letters, numbers, hyphens, and underscores.</p><p id="dialog-error" class="form-error" role="alert"></p><button type="submit" class="button primary full"><svg class="icon"><use href="#i-plus"/></svg>Create character</button></form></dialog>
|
||||||
|
<div id="toast" class="toast hidden" role="status" aria-live="polite"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -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; } }
|
||||||
|
|
@ -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()
|
||||||
Loading…
Reference in New Issue