@oxiaom/adoremix 1.0.56 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/audio8-assets/audio8-tts.tgz +0 -0
- package/package.json +1 -1
- package/src/cli.js +29 -0
- package/tts/providers/audio8.js +118 -1
- package/webui/high/js/lame.min.js +307 -307
- package/webui/high/js/worker-realtime.js +81 -81
- package/webui/low/js/lame.min.js +307 -307
- package/webui/low/js/worker-realtime.js +81 -81
|
Binary file
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -510,6 +510,35 @@ function buildProgram() {
|
|
|
510
510
|
}
|
|
511
511
|
});
|
|
512
512
|
|
|
513
|
+
audio8
|
|
514
|
+
.command('fetch-model [url]')
|
|
515
|
+
.description('单独下载 Audio8 TTS 模型(核心 ~423MB)到 ~/audio8/onnx_runtime/model/,与 audio8 install 解耦避免 install 卡住')
|
|
516
|
+
.option('--registration', '同时下载声音克隆注册子模型(约 +396MB,基础 TTS 不需要)')
|
|
517
|
+
.action(async (url, opts) => {
|
|
518
|
+
const mod = require('../tts/providers/audio8');
|
|
519
|
+
try {
|
|
520
|
+
process.exitCode = await mod.fetchModel({ url, registration: !!opts.registration });
|
|
521
|
+
} catch (e) {
|
|
522
|
+
logger.error(e.message);
|
|
523
|
+
process.exitCode = 1;
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
// 顶级命令(不依赖 audio8 group)
|
|
528
|
+
program
|
|
529
|
+
.command('audio8-fetch-model [url]')
|
|
530
|
+
.description('下载 Audio8 TTS 模型(单独使用,不依赖 audio8 install)')
|
|
531
|
+
.option('--registration', '同时下载声音克隆注册子模型(约 +396MB,基础 TTS 不需要)')
|
|
532
|
+
.action(async (url, opts) => {
|
|
533
|
+
const mod = require('../tts/providers/audio8');
|
|
534
|
+
try {
|
|
535
|
+
process.exitCode = await mod.fetchModel({ url, registration: !!opts.registration });
|
|
536
|
+
} catch (e) {
|
|
537
|
+
logger.error(e.message);
|
|
538
|
+
process.exitCode = 1;
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
513
542
|
const cfgmgr = program
|
|
514
543
|
.command('config-manager')
|
|
515
544
|
.description('设备配置管理 UI(配置 IP / 修改 config.ini / 查看日志),端口 9877,开机自启');
|
package/tts/providers/audio8.js
CHANGED
|
@@ -471,4 +471,121 @@ async function status(opts) {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
module.exports = { synthesize, checkDeps, VOICES, DEFAULT_BASE_URL, install, uninstall, status };
|
|
474
|
+
module.exports = { synthesize, checkDeps, VOICES, DEFAULT_BASE_URL, install, uninstall, status, fetchModel, downloadTo };
|
|
475
|
+
|
|
476
|
+
// === fetchModel: 单独下载 Audio8 TTS 模型 ===
|
|
477
|
+
// 源优先级:环境变量/参数指定 > hf-mirror.com(国内可达) > huggingface.co(官方,国内常被墙)
|
|
478
|
+
// 自托管:把 6 个文件传到自己服务器后 ADOREMIX_AUDIO8_MODEL_URL=https://your-host/xxx/ 或
|
|
479
|
+
// adoremix audio8-fetch-model https://your-host/xxx/
|
|
480
|
+
const MODEL_DEFAULT_URLS = process.env.ADOREMIX_AUDIO8_MODEL_URL
|
|
481
|
+
? [process.env.ADOREMIX_AUDIO8_MODEL_URL]
|
|
482
|
+
: [
|
|
483
|
+
'https://hf-mirror.com/Audio8/audio8-TTS-0.1B-ONNX-INT8/resolve/main/',
|
|
484
|
+
'https://huggingface.co/Audio8/audio8-TTS-0.1B-ONNX-INT8/resolve/main/'
|
|
485
|
+
];
|
|
486
|
+
// 模型文件清单(以仓库 runtime_manifest.json 为准,2026-10 核对)
|
|
487
|
+
// 核心运行文件 ~423MB;registration/ 子目录是声音克隆注册子模型(+396MB),基础 TTS 不需要
|
|
488
|
+
const MODEL_FILES = [
|
|
489
|
+
'runtime_manifest.json',
|
|
490
|
+
'config.json',
|
|
491
|
+
'reference_codes.npy',
|
|
492
|
+
'codec_decoder_fp16.onnx',
|
|
493
|
+
'codec_decoder_fp16.onnx.data',
|
|
494
|
+
'slow_ar_int8.onnx',
|
|
495
|
+
'slow_ar_int8.onnx.data',
|
|
496
|
+
'fast_ar_int8.onnx',
|
|
497
|
+
'fast_ar_int8.onnx.data',
|
|
498
|
+
'tokenizer/tokenizer.json'
|
|
499
|
+
];
|
|
500
|
+
const MODEL_REGISTRATION_FILES = [
|
|
501
|
+
'registration/registration_manifest.json',
|
|
502
|
+
'registration/codec_encoder_fp16.onnx',
|
|
503
|
+
'registration/codec_encoder_fp16.onnx.data'
|
|
504
|
+
];
|
|
505
|
+
|
|
506
|
+
// 下载单文件到 target。HF 风格 /resolve/ 会 301/302/307/308 跳 CDN,
|
|
507
|
+
// Node 的 http.get 不自动跟随重定向,必须手动跳(最多 5 跳)。
|
|
508
|
+
function downloadTo(url, target, file) {
|
|
509
|
+
return new Promise((resolve, reject) => {
|
|
510
|
+
const get = (u, hops) => {
|
|
511
|
+
if (hops > 5) return reject(new Error(file + ' 重定向超过 5 跳'));
|
|
512
|
+
const lib = u.startsWith('https:') ? https : http;
|
|
513
|
+
const req = lib.get(u, response => {
|
|
514
|
+
if ([301, 302, 303, 307, 308].indexOf(response.statusCode) >= 0) {
|
|
515
|
+
const loc = response.headers.location;
|
|
516
|
+
response.resume();
|
|
517
|
+
if (!loc) return reject(new Error(file + ' 重定向缺少 Location'));
|
|
518
|
+
return get(new URL(loc, u).href, hops + 1);
|
|
519
|
+
}
|
|
520
|
+
if (response.statusCode !== 200) {
|
|
521
|
+
response.resume();
|
|
522
|
+
return reject(new Error('HTTP ' + response.statusCode));
|
|
523
|
+
}
|
|
524
|
+
const total = parseInt(response.headers['content-length'] || '0', 10);
|
|
525
|
+
const ws = fs.createWriteStream(target);
|
|
526
|
+
let got = 0, lastLog = 0;
|
|
527
|
+
response.on('data', c => {
|
|
528
|
+
got += c.length;
|
|
529
|
+
// 大文件(model.onnx.data ~572MB)每 100MB 报一次进度,避免长时间无输出像卡死
|
|
530
|
+
if (got - lastLog >= 100 * 1024 * 1024) {
|
|
531
|
+
lastLog = got;
|
|
532
|
+
logger.log(` ${file}: ${(got / 1048576).toFixed(0)}MB` + (total ? ` / ${(total / 1048576).toFixed(0)}MB` : ''));
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
response.pipe(ws);
|
|
536
|
+
ws.on('finish', () => ws.close(() => resolve({ file, got, total })));
|
|
537
|
+
ws.on('error', reject);
|
|
538
|
+
});
|
|
539
|
+
req.on('error', reject);
|
|
540
|
+
// 10 分钟超时:572MB 在 ≥1MB/s 的链路上够用
|
|
541
|
+
req.setTimeout(600000, () => req.destroy(new Error(file + ' 超时(10min)')));
|
|
542
|
+
};
|
|
543
|
+
get(url, 0);
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async function fetchModel(opts) {
|
|
548
|
+
opts = opts || {};
|
|
549
|
+
// 目标目录必须与 systemd 单元一致(WorkingDirectory=~/audio8/onnx_runtime + --model-dir ./model)
|
|
550
|
+
const targetDir = process.env.ADOREMIX_AUDIO8_MODEL_DIR
|
|
551
|
+
|| path.join(os.homedir(), 'audio8', 'onnx_runtime', 'model');
|
|
552
|
+
const baseUrls = opts.url ? [opts.url] : MODEL_DEFAULT_URLS;
|
|
553
|
+
// --registration / ADOREMIX_AUDIO8_WITH_REGISTRATION=1 时追加声音克隆注册子模型(+396MB)
|
|
554
|
+
const files = (opts.registration || process.env.ADOREMIX_AUDIO8_WITH_REGISTRATION === '1')
|
|
555
|
+
? MODEL_FILES.concat(MODEL_REGISTRATION_FILES) : MODEL_FILES;
|
|
556
|
+
|
|
557
|
+
logger.log('Audio8 模型下载 → ' + targetDir);
|
|
558
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
559
|
+
|
|
560
|
+
let ok = 0, fail = 0;
|
|
561
|
+
for (const f of files) {
|
|
562
|
+
let done = false, lastErr = null;
|
|
563
|
+
// 文件清单含子目录(如 tokenizer/tokenizer.json),先建父目录
|
|
564
|
+
const target = path.join(targetDir, f);
|
|
565
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
566
|
+
for (const base of baseUrls) {
|
|
567
|
+
try {
|
|
568
|
+
logger.log(` → ${f}(源 ${new URL(base).host})`);
|
|
569
|
+
const r = await downloadTo(base.replace(/\/+$/, '') + '/' + f, target, f);
|
|
570
|
+
logger.log(` ✓ ${f} 完成 ${(r.got / 1048576).toFixed(1)}MB`);
|
|
571
|
+
done = true;
|
|
572
|
+
break;
|
|
573
|
+
} catch (e) {
|
|
574
|
+
lastErr = e;
|
|
575
|
+
logger.warn(` ✗ 源 ${new URL(base).host} 失败: ${e.message}`);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (done) { ok++; }
|
|
579
|
+
else {
|
|
580
|
+
fail++;
|
|
581
|
+
logger.error(` ✗ ${f} 所有源均失败: ${lastErr ? lastErr.message : '未知错误'}`);
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if (fail > 0) {
|
|
585
|
+
logger.error(`失败 ${fail} 个文件,模型不完整。可换源自试: adoremix audio8-fetch-model <url>/`);
|
|
586
|
+
return 1;
|
|
587
|
+
}
|
|
588
|
+
logger.ok(`Audio8 模型就绪(${ok} 个文件): ${targetDir}`);
|
|
589
|
+
logger.log('重启服务生效: systemctl restart audio8-tts');
|
|
590
|
+
return 0;
|
|
591
|
+
}
|