Support TOML config, project venv, and public packaging.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+12
-2
@@ -1,5 +1,13 @@
|
||||
# --- 本机覆盖(勿提交)---
|
||||
# --- 本机覆盖 / 密钥(永不提交)---
|
||||
config/local.toml
|
||||
config/local.json
|
||||
.secrets/
|
||||
*.token
|
||||
|
||||
# --- 项目 venv ---
|
||||
.venv/
|
||||
venv/
|
||||
env/
|
||||
|
||||
# --- 过程与缓存(保留 .gitkeep 占位)---
|
||||
data/**
|
||||
@@ -32,6 +40,8 @@ __pycache__/
|
||||
*.egg-info/
|
||||
.pytest_cache/
|
||||
.codebase-index/
|
||||
dist/
|
||||
build/
|
||||
|
||||
# --- 编辑器 / OS ---
|
||||
.DS_Store
|
||||
@@ -40,6 +50,6 @@ Thumbs.db
|
||||
.vscode/
|
||||
*.swp
|
||||
|
||||
# --- 索引占位 ---
|
||||
# --- 占位 ---
|
||||
!index/.gitkeep
|
||||
!input/lyrics/.gitkeep
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# 复制目录 .secrets/ 并放入本地 token 文件(勿提交)。
|
||||
# 例如:
|
||||
# .secrets/github.token # 仅本地 push / gh API
|
||||
# .secrets/testserver_gitea.token
|
||||
#
|
||||
# 文件内容为一行 token,无引号。
|
||||
@@ -57,14 +57,16 @@ python songforge\songforge.py qc --run <run_id> --baseline
|
||||
| 时长 | 完整歌 **150–200** 秒(默认跟风格字典;pop 常 180) |
|
||||
| 前奏 | 8 小节器乐 hook,第一拍进鼓;CLI `assemble` 自动注入 |
|
||||
|
||||
改算法参数只动 `config/default.json`;本机路径用 `config/local.json`(gitignore)。不要改 `data/runs/` 里的 JSON。
|
||||
改算法参数只动 `config/default.toml`;本机路径用 `config/local.toml`(gitignore)。不要改 `data/runs/` 里的过程 JSON。
|
||||
|
||||
配置优先级:
|
||||
|
||||
```text
|
||||
命令行 > SONGFORGE_* > config/local.json > config/default.json > DEFAULTS
|
||||
命令行 > SONGFORGE_* > local.toml > default.toml > DEFAULTS
|
||||
```
|
||||
|
||||
CLI 用项目 `.venv`;QC 用 `local.toml` 的 `qc_python`(可与 ComfyUI venv 分离)。
|
||||
|
||||
## 4. 目录地图(项目 vs 数据)
|
||||
|
||||
路径键在 `config/default.json` → `paths`。相对 `user/default/workflows`:
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 lsuen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,26 +1,53 @@
|
||||
# songforge
|
||||
|
||||
本地创作者用的 AI 歌曲生成 CLI。固定模型 + 铁律注入 + 密度硬校验 + QC 验收,稳定产出带专属声线的完整歌曲。
|
||||
本地 ACE-Step 生歌 CLI:锁定模型与声线 LoRA、铁律前奏注入、歌词密度硬校验、QC 验收。
|
||||
|
||||
本目录是**独立 Git 仓**:
|
||||
|
||||
- `main`:只跟踪项目资产(代码 / `config/` / 基线 / 文档)
|
||||
- `archive/full-snapshot`:本地备份过程数据(`data/`、`index/catalog.jsonl`、`_archive/`);**勿默认 push**
|
||||
- `cache/` 可重建(约数 GB),不进 archive
|
||||
自己用爽是第一目标;代码按 MIT 开源,方便别人在 ComfyUI + ACE-Step 上复用同一套流水线。
|
||||
|
||||
| 文档 | 给谁 |
|
||||
|------|------|
|
||||
| [`AGENTS.md`](AGENTS.md) | **远程 / channel Agent**(上下文不够时重读这份做歌) |
|
||||
| [`../生歌规则.md`](../生歌规则.md) | 参数/铁律/踩坑唯一规范 |
|
||||
| [`docs/使用手册.md`](docs/使用手册.md) | 人类操作手册 |
|
||||
| [`AGENTS.md`](AGENTS.md) | Agent / 自动化(做歌时重读) |
|
||||
| [`docs/使用手册.md`](docs/使用手册.md) | 人类操作 |
|
||||
|
||||
## 30 秒上手
|
||||
## 两个 Python 环境(别混)
|
||||
|
||||
工作目录必须是 `user/default/workflows`:
|
||||
| 环境 | 用途 | 怎么来 |
|
||||
|------|------|--------|
|
||||
| **项目 `.venv`** | CLI:`doctor` / `target` / `check` / `gen` / `catalog` | `scripts\setup_venv.ps1` |
|
||||
| **`qc_python`** | QC 音频栈(librosa / torch / demucs) | `config/local.toml` 指向 ComfyUI venv,或自建重环境 |
|
||||
|
||||
```powershell
|
||||
cd D:\CodeFiles\Thinking\ComfyUI-MiniMaxH3\user\default\workflows
|
||||
# 1) 建 CLI 环境(推荐 Python 3.13 / ≥3.11)
|
||||
cd path\to\songforge
|
||||
.\scripts\setup_venv.ps1
|
||||
|
||||
# 2) 本机路径
|
||||
copy config\local.toml.example config\local.toml
|
||||
# 编辑 comfy_root / qc_python / music_dir
|
||||
|
||||
# 3) 工作目录:包的父目录(文件夹名必须是 songforge)
|
||||
cd ..
|
||||
.\songforge\.venv\Scripts\python.exe songforge\songforge.py doctor
|
||||
```
|
||||
|
||||
嵌套在 ComfyUI 时父目录就是 `user\default\workflows`。
|
||||
|
||||
## 配置:TOML vs JSON
|
||||
|
||||
| 文件 | 格式 | 作用 |
|
||||
|------|------|------|
|
||||
| `config/default.toml` | **TOML** | 算法 / 采样 / 相对路径(可提交) |
|
||||
| `config/local.toml` | **TOML** | 本机绝对路径(gitignore) |
|
||||
| `config/styles.json` `lexicon.json` | JSON | 风格字典 / 禁词(数据) |
|
||||
| `config/baseline/*.json` | JSON | QC 基线数值 |
|
||||
| `workflows/*.json` 与 Comfy 模板 | JSON | **只有** workflow 图用 JSON |
|
||||
|
||||
优先级:`命令行 > SONGFORGE_* > local.toml > default.toml > DEFAULTS`
|
||||
(仍可读旧的 `local.json` / `default.json`,同名时 TOML 覆盖。)
|
||||
|
||||
## 30 秒流水线
|
||||
|
||||
```powershell
|
||||
python songforge\songforge.py doctor
|
||||
python songforge\songforge.py target --style pop --bpm 104 --dur 180
|
||||
python songforge\songforge.py check --style pop --title 歌名 --lyrics-file songforge\input\lyrics\歌名.txt
|
||||
@@ -29,7 +56,7 @@ python songforge\songforge.py qc --run gen-<时间戳> --baseline
|
||||
python songforge\songforge.py catalog --limit 20
|
||||
```
|
||||
|
||||
`qc` 必须带 `--baseline`。首次本机复制 `config/local.json.example` → `config/local.json` 填 Comfy 根与 QC Python。
|
||||
`qc` 必须带 `--baseline`。
|
||||
|
||||
## 硬约束(摘要)
|
||||
|
||||
@@ -39,44 +66,31 @@ python songforge\songforge.py catalog --limit 20
|
||||
| 采样 | shift=5.5 / steps=28 / cfg=2.0 / temperature=0.68 |
|
||||
| 时长 | 完整歌 150–200 秒 |
|
||||
| 前奏 | 8 小节器乐 hook;CLI 自动注入 |
|
||||
| 配置 | 算法锁 `config/default.json`;本机路径 `config/local.json` |
|
||||
|
||||
## 项目资产 vs 过程数据
|
||||
|
||||
| 级别 | 路径 | 是否进 `main` |
|
||||
|------|------|----------------|
|
||||
| 项目 | `cli/` `core/` `config/*.json`(除 local) `config/baseline/` `workflows/` `docs/` | 是 |
|
||||
| 本机 | `config/local.json` | 否(gitignore) |
|
||||
| 过程 | `data/runs/YYYY-MM-DD/gen-*/` `data/tmp/` | 否 |
|
||||
| 索引 | `index/catalog.jsonl` | 否(可 `--rebuild`) |
|
||||
| 缓存 | `cache/qc` `cache/style` | 否 |
|
||||
| 音频 | ComfyUI `output/MyMusic/` | 不在包内 |
|
||||
## 目录(项目 vs 数据)
|
||||
|
||||
```
|
||||
songforge/
|
||||
AGENTS.md / README.md / songforge.py
|
||||
config/ # default + styles + lexicon + local.example
|
||||
baseline/ # qc_baseline*.json + style_ref.json
|
||||
local.json # 本机路径(勿提交)
|
||||
cli/ core/ rules/ lyrics/
|
||||
input/lyrics/ # 新歌词投放
|
||||
data/runs/YYYY-MM-DD/ # gen 正式产物
|
||||
data/tmp/YYYY-MM-DD/ # doctor/check 会话
|
||||
index/catalog.jsonl # 全局元数据索引
|
||||
cache/ # QC / 风格特征
|
||||
docs/ _archive/
|
||||
songforge/ # Git 仓根 = 包根
|
||||
config/default.toml # 算法配置
|
||||
config/local.toml # 本机(勿提交)
|
||||
config/baseline/ # QC 基线
|
||||
cli/ core/ rules/ ...
|
||||
data/runs/YYYY-MM-DD/ # gen 产物
|
||||
data/tmp/YYYY-MM-DD/ # doctor/check
|
||||
index/catalog.jsonl
|
||||
workflows/template.json # 包内备用模板
|
||||
.venv/ # CLI 专用(勿提交)
|
||||
.secrets/ # 本地 token(勿提交)
|
||||
```
|
||||
|
||||
## 配置优先级
|
||||
音频成品仍在 ComfyUI `output/MyMusic/`(可用 `music_dir` 覆盖)。
|
||||
|
||||
```
|
||||
命令行 > SONGFORGE_* 环境变量 > config/local.json > config/default.json > DEFAULTS
|
||||
```
|
||||
## Git
|
||||
|
||||
模型与采样铁律只在 `default.json`,不要放进 local。
|
||||
- `main`:项目资产
|
||||
- `archive/full-snapshot`:本地过程数据备份,**不要 push**
|
||||
- `.secrets/`、`config/local.toml`、`.venv/`、`data/**` 均已 ignore
|
||||
|
||||
## 日志
|
||||
## License
|
||||
|
||||
- `gen` → `data/runs/<日>/<run_id>/run.log`(JSONL)
|
||||
- `doctor` / `check` → `data/tmp/<日>/<cmd>-*/run.log`
|
||||
- `--log-level` / `--quiet` 全局生效
|
||||
MIT — 见 [LICENSE](LICENSE)。
|
||||
|
||||
+9
-2
@@ -36,8 +36,15 @@ def cmd_doctor(args):
|
||||
print(" catalog %s" % layout["catalog"])
|
||||
print(" qc_cache %s" % layout["qc_cache"])
|
||||
print(" 音频输出 %s" % layout["audio_out"])
|
||||
local_cfg = os.path.join(ROOT, "songforge", "config", "local.json")
|
||||
print(" local.json %s" % ("有" if os.path.isfile(local_cfg) else "无(可用 local.json.example)"))
|
||||
local_toml = os.path.join(ROOT, "songforge", "config", "local.toml")
|
||||
local_json = os.path.join(ROOT, "songforge", "config", "local.json")
|
||||
if os.path.isfile(local_toml):
|
||||
print(" local.toml 有")
|
||||
elif os.path.isfile(local_json):
|
||||
print(" local.json 有(建议迁到 local.toml)")
|
||||
else:
|
||||
print(" local.toml 无(复制 config/local.toml.example)")
|
||||
print(" CLI python %s" % loader.python_hint())
|
||||
|
||||
print("== 根目录卫生 ==")
|
||||
pkg = layout["pkg"]
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
{
|
||||
"_comment": "songforge 唯一事实来源。改这里,不要改脚本里的硬编码常量。",
|
||||
|
||||
"engine": {
|
||||
"server": "http://127.0.0.1:8188",
|
||||
"timeout_sec": 3600,
|
||||
"poll_interval_sec": 10,
|
||||
"submit_retries": 3
|
||||
},
|
||||
|
||||
"model": {
|
||||
"checkpoint": "ace_step_1.5_turbo_swl_fused.safetensors",
|
||||
"lora": "swl_voice_best_ep257.safetensors",
|
||||
"lora_model_strength": 0.5,
|
||||
"lora_clip_strength": 0.5,
|
||||
"denied_checkpoints": [
|
||||
"yue2_3b_int8_convrot.safetensors",
|
||||
"ace_step_1.5_turbo_aio.safetensors"
|
||||
]
|
||||
},
|
||||
|
||||
"sampler": {
|
||||
"shift": 5.5,
|
||||
"sampling": "flow",
|
||||
"steps": 28,
|
||||
"cfg": 2.0,
|
||||
"sampler_name": "euler",
|
||||
"scheduler": "simple",
|
||||
"denoise": 1.0
|
||||
},
|
||||
|
||||
"encode": {
|
||||
"cfg_scale": 3.0,
|
||||
"temperature": 0.68,
|
||||
"top_p": 0.88,
|
||||
"top_k": 50,
|
||||
"min_p": 0.02,
|
||||
"generate_audio_codes": true,
|
||||
"timesignature": "4"
|
||||
},
|
||||
|
||||
"paths": {
|
||||
"_comment": "相对路径均相对 user/default/workflows。本机绝对路径放 local.json(gitignore)。音频在 ComfyUI/output/<output_prefix>/。过程物按日落在 data/runs|tmp/YYYY-MM-DD/。",
|
||||
"workflow_template": "urbanhiphop-身体先听懂.json",
|
||||
"runs_dir": "songforge/data/runs",
|
||||
"tmp_dir": "songforge/data/tmp",
|
||||
"lyrics_dir": "songforge/input/lyrics",
|
||||
"qc_cache_dir": "songforge/cache/qc",
|
||||
"style_cache_dir": "songforge/cache/style",
|
||||
"index_dir": "songforge/index",
|
||||
"catalog_file": "songforge/index/catalog.jsonl",
|
||||
"baseline_dir": "songforge/config/baseline",
|
||||
"comfy_root": null,
|
||||
"qc_python": null,
|
||||
"music_dir": null,
|
||||
"output_prefix": "MyMusic",
|
||||
"output_format": "flac"
|
||||
},
|
||||
|
||||
"song": {
|
||||
"language": "zh",
|
||||
"time_signature": "4",
|
||||
"duration_range": [150, 200],
|
||||
"_duration_extra_comment": "duration_extra_ranges 供短视频/口水歌等场景显式放行短时长,不削弱主区间。主区间是 35 首已验证实歌的经验范围,短时长没有对应实歌背书,所以必须显式列出而不是直接放宽。",
|
||||
"duration_extra_ranges": [[100, 130]]
|
||||
},
|
||||
|
||||
"lyrics": {
|
||||
"_comment": "死心塌地时长对应关系。阈值由 8 首已验证可生成的歌实测反推,不是理论值;改前先跑 selftest 实歌回归。",
|
||||
"_calibrated_on": "remake_v5.py 的 8 首实歌:每可唱小节 4.56~7.64 音节(均值 6.17),每句 5.9~7.4 音节(均值 6.7)",
|
||||
"sing_bar_ratio": 0.70,
|
||||
"intro_bars": 8,
|
||||
"syllable_per_bar_min": 4.40,
|
||||
"syllable_per_bar_max": 7.80,
|
||||
"line_syllable_max": 12,
|
||||
"ideal_line_syllable": [5, 12],
|
||||
|
||||
"_profile_comment": "密度档。default = 人声填满整首(中文说唱/流行)。sparse = 音乐主导、人声点缀(英文低声吟唱/纯器乐周边)。",
|
||||
"_profile_why": "default 档是按 8 首'人声填满全曲'的实歌反推的。直接拿它校验第三张那种'音乐当主角、人声只是点缀'的写法,会把只有几句 ooh ooh 的低音吟唱判成歌词过少,逼着写满 254 音节以上——结果就是'只有人声没有音乐',正好和目标相反。所以稀疏写法必须用另一套阈值,不能共用。",
|
||||
"profiles": {
|
||||
"sparse": {
|
||||
"_comment": "稀疏档:可唱小节只占 25%(其余留给器乐),句子下限放宽到 3 音节,允许 ooh ooh / mmm 这类短语气词。",
|
||||
"sing_bar_ratio": 0.25,
|
||||
"syllable_per_bar_min": 4.40,
|
||||
"syllable_per_bar_max": 7.80,
|
||||
"line_syllable_max": 12,
|
||||
"ideal_line_syllable": [3, 12]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
"rules": {
|
||||
"trigger_word": "swlvoice",
|
||||
"intro_bars": 8
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
# songforge 算法与相对路径的唯一事实来源(可提交)。
|
||||
# 本机绝对路径请写 local.toml(gitignore),勿写进本文件。
|
||||
# ComfyUI workflow 图仍是 JSON,只放在 workflows/ 或 Comfy 模板路径下。
|
||||
|
||||
[engine]
|
||||
server = "http://127.0.0.1:8188"
|
||||
timeout_sec = 3600
|
||||
poll_interval_sec = 10
|
||||
submit_retries = 3
|
||||
|
||||
[model]
|
||||
checkpoint = "ace_step_1.5_turbo_swl_fused.safetensors"
|
||||
lora = "swl_voice_best_ep257.safetensors"
|
||||
lora_model_strength = 0.5
|
||||
lora_clip_strength = 0.5
|
||||
denied_checkpoints = [
|
||||
"yue2_3b_int8_convrot.safetensors",
|
||||
"ace_step_1.5_turbo_aio.safetensors",
|
||||
]
|
||||
|
||||
[sampler]
|
||||
shift = 5.5
|
||||
sampling = "flow"
|
||||
steps = 28
|
||||
cfg = 2.0
|
||||
sampler_name = "euler"
|
||||
scheduler = "simple"
|
||||
denoise = 1.0
|
||||
|
||||
[encode]
|
||||
cfg_scale = 3.0
|
||||
temperature = 0.68
|
||||
top_p = 0.88
|
||||
top_k = 50
|
||||
min_p = 0.02
|
||||
generate_audio_codes = true
|
||||
timesignature = "4"
|
||||
|
||||
# 相对路径相对「workflows 父目录」(嵌套在 ComfyUI 时)或克隆仓的父目录。
|
||||
# 本机 comfy_root / qc_python / music_dir 放 local.toml。
|
||||
[paths]
|
||||
workflow_template = "urbanhiphop-身体先听懂.json"
|
||||
runs_dir = "songforge/data/runs"
|
||||
tmp_dir = "songforge/data/tmp"
|
||||
lyrics_dir = "songforge/input/lyrics"
|
||||
qc_cache_dir = "songforge/cache/qc"
|
||||
style_cache_dir = "songforge/cache/style"
|
||||
index_dir = "songforge/index"
|
||||
catalog_file = "songforge/index/catalog.jsonl"
|
||||
baseline_dir = "songforge/config/baseline"
|
||||
output_prefix = "MyMusic"
|
||||
output_format = "flac"
|
||||
|
||||
[song]
|
||||
language = "zh"
|
||||
time_signature = "4"
|
||||
duration_range = [150, 200]
|
||||
# 短视频等场景显式放行;不削弱主区间
|
||||
duration_extra_ranges = [[100, 130]]
|
||||
|
||||
# 死心塌地时长对应:阈值由 8 首已验证实歌反推,改前先跑 selftest。
|
||||
[lyrics]
|
||||
sing_bar_ratio = 0.70
|
||||
intro_bars = 8
|
||||
syllable_per_bar_min = 4.40
|
||||
syllable_per_bar_max = 7.80
|
||||
line_syllable_max = 12
|
||||
ideal_line_syllable = [5, 12]
|
||||
|
||||
# sparse = 音乐主导、人声点缀(英文低声吟唱等)
|
||||
[lyrics.profiles.sparse]
|
||||
sing_bar_ratio = 0.25
|
||||
syllable_per_bar_min = 4.40
|
||||
syllable_per_bar_max = 7.80
|
||||
line_syllable_max = 12
|
||||
ideal_line_syllable = [3, 12]
|
||||
|
||||
[rules]
|
||||
trigger_word = "swlvoice"
|
||||
intro_bars = 8
|
||||
+37
-8
@@ -1,13 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""配置加载与覆盖。
|
||||
|
||||
优先级:命令行 > 环境变量 > local.json > default.json > 内置 DEFAULTS。
|
||||
优先级:命令行 > 环境变量 > local.toml|json > default.toml|json > DEFAULTS。
|
||||
|
||||
local.json 放本机绝对路径(gitignore),见 local.json.example。
|
||||
算法配置用 TOML(与 ComfyUI workflow JSON 分流)。
|
||||
styles.json / lexicon.json / baseline/*.json 仍是数据文件,保持 JSON。
|
||||
本机绝对路径只写 local.toml(gitignore)。
|
||||
"""
|
||||
import copy
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
try:
|
||||
import tomllib
|
||||
except ModuleNotFoundError: # Python < 3.11
|
||||
import tomli as tomllib # type: ignore
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
CONFIG_DIR = os.path.join(ROOT, "songforge", "config")
|
||||
@@ -69,19 +77,35 @@ def _deep_merge(base, patch):
|
||||
return base
|
||||
|
||||
|
||||
def _read(name):
|
||||
def _read_json(name):
|
||||
p = os.path.join(CONFIG_DIR, name)
|
||||
if not os.path.exists(p):
|
||||
if not os.path.isfile(p):
|
||||
return {}
|
||||
with open(p, encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
def _read_toml(name):
|
||||
p = os.path.join(CONFIG_DIR, name)
|
||||
if not os.path.isfile(p):
|
||||
return {}
|
||||
with open(p, "rb") as f:
|
||||
return tomllib.load(f)
|
||||
|
||||
|
||||
def _read_layer(basename):
|
||||
"""同名 .json 与 .toml:先 json 再 toml,toml 覆盖(迁移期兼容)。"""
|
||||
out = {}
|
||||
_deep_merge(out, _read_json(basename + ".json"))
|
||||
_deep_merge(out, _read_toml(basename + ".toml"))
|
||||
return out
|
||||
|
||||
|
||||
def load(overrides=None):
|
||||
"""返回最终配置 dict。overrides 是 {'sampler.shift': 5.5} 这种点号路径。"""
|
||||
cfg = copy.deepcopy(DEFAULTS)
|
||||
_deep_merge(cfg, _read("default.json"))
|
||||
_deep_merge(cfg, _read("local.json"))
|
||||
_deep_merge(cfg, _read_layer("default"))
|
||||
_deep_merge(cfg, _read_layer("local"))
|
||||
_deep_merge(cfg, _env_overrides())
|
||||
if overrides:
|
||||
for path, val in overrides.items():
|
||||
@@ -167,13 +191,18 @@ def _env_overrides():
|
||||
|
||||
|
||||
def styles():
|
||||
return _read("styles.json")
|
||||
return _read_json("styles.json")
|
||||
|
||||
|
||||
def lexicon():
|
||||
return _read("lexicon.json")
|
||||
return _read_json("lexicon.json")
|
||||
|
||||
|
||||
def baseline_path(name):
|
||||
"""config/baseline/<name> 绝对路径。"""
|
||||
return os.path.join(CONFIG_DIR, "baseline", name)
|
||||
|
||||
|
||||
def python_hint():
|
||||
"""当前解释器信息(doctor 用)。"""
|
||||
return "%s (%s)" % (sys.executable, sys.version.split()[0])
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"_comment": "复制为 local.json(已 gitignore)。只放本机绝对路径,勿提交。",
|
||||
"paths": {
|
||||
"comfy_root": "D:/CodeFiles/Thinking/ComfyUI-MiniMaxH3",
|
||||
"qc_python": "C:/comfyui-venv/Scripts/python.exe",
|
||||
"music_dir": "D:/CodeFiles/Thinking/ComfyUI-MiniMaxH3/output/MyMusic"
|
||||
},
|
||||
"engine": {
|
||||
"server": "http://127.0.0.1:8188"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
# 复制为 local.toml(已 gitignore)。只放本机绝对路径,勿提交。
|
||||
# CLI 用项目 .venv;QC 音频栈可继续指向 ComfyUI 专用 venv。
|
||||
|
||||
[paths]
|
||||
comfy_root = "D:/CodeFiles/Thinking/ComfyUI-MiniMaxH3"
|
||||
qc_python = "C:/comfyui-venv/Scripts/python.exe"
|
||||
music_dir = "D:/CodeFiles/Thinking/ComfyUI-MiniMaxH3/output/MyMusic"
|
||||
|
||||
[engine]
|
||||
server = "http://127.0.0.1:8188"
|
||||
+5
-5
@@ -165,7 +165,7 @@ python songforge\songforge.py selftest
|
||||
|------|------|------------------------|
|
||||
| 项目 | 新歌词 | `songforge/input/lyrics/` |
|
||||
| 项目 | QC/风格基线 | `songforge/config/baseline/` |
|
||||
| 本机 | 绝对路径覆盖 | `songforge/config/local.json`(gitignore) |
|
||||
| 本机 | 绝对路径覆盖 | `songforge/config/local.toml`(gitignore) |
|
||||
| 数据 | gen 产物 | `songforge/data/runs/YYYY-MM-DD/` |
|
||||
| 数据 | 临时日志 | `songforge/data/tmp/YYYY-MM-DD/` |
|
||||
| 数据 | 全局索引 | `songforge/index/catalog.jsonl` |
|
||||
@@ -178,8 +178,8 @@ Agent 远程做歌请读 `songforge/AGENTS.md`。
|
||||
|
||||
| 想改 | 文件 |
|
||||
|------|------|
|
||||
| 模型 / 采样 / 时长区间 / 相对路径 | `config/default.json` |
|
||||
| 本机 Comfy 根 / QC Python / 音乐目录 | `config/local.json`(从 example 复制) |
|
||||
| 模型 / 采样 / 时长区间 / 相对路径 | `config/default.toml` |
|
||||
| 本机 Comfy 根 / QC Python / 音乐目录 | `config/local.toml`(从 example 复制) |
|
||||
| 风格 bpm/key/乐器/情绪 | `config/styles.json` |
|
||||
| 禁词 | `config/lexicon.json` |
|
||||
| QC 软阈值 | `config/baseline/qc_baseline.json`(工具校准,勿手拍) |
|
||||
@@ -190,10 +190,10 @@ Agent 远程做歌请读 `songforge/AGENTS.md`。
|
||||
### 3.2 优先级
|
||||
|
||||
```text
|
||||
命令行 > SONGFORGE_* 环境变量 > config/local.json > config/default.json > DEFAULTS
|
||||
命令行 > SONGFORGE_* 环境变量 > local.toml > default.toml > DEFAULTS
|
||||
```
|
||||
|
||||
常用环境变量:`SONGFORGE_SERVER`、`SONGFORGE_COMFY_ROOT`、`SONGFORGE_QC_PYTHON`、`SONGFORGE_MUSIC_DIR`、`SONGFORGE_SHIFT`、`SONGFORGE_RUNS`。
|
||||
算法配置用 TOML;Comfy workflow 图仍是 JSON。常用环境变量:`SONGFORGE_SERVER`、`SONGFORGE_COMFY_ROOT`、`SONGFORGE_QC_PYTHON`、`SONGFORGE_MUSIC_DIR`、`SONGFORGE_SHIFT`、`SONGFORGE_RUNS`。
|
||||
|
||||
### 3.3 已锁定默认(勿随意改)
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=68"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "songforge"
|
||||
version = "0.2.0"
|
||||
description = "Local ACE-Step song generation CLI with locked voice LoRA, density checks, and QC."
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
license = { text = "MIT" }
|
||||
authors = [{ name = "lsuen" }]
|
||||
keywords = ["comfyui", "ace-step", "music", "lyrics", "cli"]
|
||||
dependencies = [
|
||||
"tomli>=2.0.1; python_version < '3.11'",
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
qc = [
|
||||
"librosa>=0.10",
|
||||
"soundfile>=0.12",
|
||||
"numpy>=1.24",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/lsuen/songforge"
|
||||
Repository = "https://github.com/lsuen/songforge"
|
||||
|
||||
# 入口:在父目录执行 `python songforge/songforge.py`(包名=文件夹名)。
|
||||
# 或仓库内:`.\.venv\Scripts\python.exe songforge.py`(脚本会把父目录加入 sys.path)。
|
||||
@@ -0,0 +1,4 @@
|
||||
# songforge CLI(轻量)。Python >= 3.11(推荐 3.13)。
|
||||
# QC 音频栈默认走 config/local.toml 的 qc_python(如 ComfyUI venv),不必装进本环境。
|
||||
|
||||
tomli>=2.0.1; python_version < "3.11"
|
||||
@@ -0,0 +1,41 @@
|
||||
# Rebuild project .venv for CLI. QC can keep using ComfyUI venv via local.toml.
|
||||
$ErrorActionPreference = "Stop"
|
||||
$Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path)
|
||||
Set-Location $Root
|
||||
|
||||
$PyLauncher = $null
|
||||
$PyArgs = @()
|
||||
foreach ($pair in @(
|
||||
@("py", @("-3.13")),
|
||||
@("py", @("-3.12")),
|
||||
@("py", @("-3.11")),
|
||||
@("python", @())
|
||||
)) {
|
||||
$exe = $pair[0]
|
||||
$a = $pair[1]
|
||||
try {
|
||||
$ver = & $exe @($a + @("-c", "import sys; print('%d.%d' % sys.version_info[:2])")) 2>$null
|
||||
if ($ver -match '^3\.(1[1-9]|[2-9]\d)') {
|
||||
$PyLauncher = $exe
|
||||
$PyArgs = $a
|
||||
break
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
if (-not $PyLauncher) {
|
||||
Write-Error "Need Python >= 3.11 (try: py -3.13)"
|
||||
}
|
||||
|
||||
Write-Host "Using: $PyLauncher $($PyArgs -join ' ')"
|
||||
if (Test-Path .venv) {
|
||||
Write-Host "Removing old .venv ..."
|
||||
Remove-Item -Recurse -Force .venv
|
||||
}
|
||||
& $PyLauncher @($PyArgs + @("-m", "venv", ".venv"))
|
||||
& .\.venv\Scripts\python.exe -m pip install -U pip
|
||||
& .\.venv\Scripts\python.exe -m pip install -r requirements.txt
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "OK: .venv ready"
|
||||
Write-Host "CLI: .\.venv\Scripts\python.exe songforge.py doctor"
|
||||
Write-Host "QC: set paths.qc_python in config\local.toml"
|
||||
+5
-1
@@ -189,7 +189,11 @@ def _campplus():
|
||||
return _S["campplus"]
|
||||
import torch
|
||||
root = os.environ.get("SONGFORGE_COMFY_ROOT") or os.environ.get(
|
||||
"COMFY_ROOT") or r"D:\CodeFiles\Thinking\ComfyUI-MiniMaxH3"
|
||||
"COMFY_ROOT")
|
||||
if not root:
|
||||
raise RuntimeError(
|
||||
"缺少 SONGFORGE_COMFY_ROOT(由 songforge qc 注入,或写在 "
|
||||
"config/local.toml 的 paths.comfy_root)")
|
||||
for p in (root, os.path.dirname(os.path.abspath(__file__))):
|
||||
sys.path.insert(0, p)
|
||||
sys.path.insert(0, os.path.join(p, "custom_nodes",
|
||||
|
||||
Reference in New Issue
Block a user