@oxiaom/adoremix 1.0.57 → 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/package.json +1 -1
- package/src/cli.js +7 -5
- package/tts/providers/audio8.js +97 -42
- 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
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -512,11 +512,12 @@ function buildProgram() {
|
|
|
512
512
|
|
|
513
513
|
audio8
|
|
514
514
|
.command('fetch-model [url]')
|
|
515
|
-
.description('单独下载 Audio8 TTS
|
|
516
|
-
.
|
|
515
|
+
.description('单独下载 Audio8 TTS 模型(核心 ~423MB)到 ~/audio8/onnx_runtime/model/,与 audio8 install 解耦避免 install 卡住')
|
|
516
|
+
.option('--registration', '同时下载声音克隆注册子模型(约 +396MB,基础 TTS 不需要)')
|
|
517
|
+
.action(async (url, opts) => {
|
|
517
518
|
const mod = require('../tts/providers/audio8');
|
|
518
519
|
try {
|
|
519
|
-
process.exitCode = await mod.fetchModel({ url });
|
|
520
|
+
process.exitCode = await mod.fetchModel({ url, registration: !!opts.registration });
|
|
520
521
|
} catch (e) {
|
|
521
522
|
logger.error(e.message);
|
|
522
523
|
process.exitCode = 1;
|
|
@@ -527,10 +528,11 @@ function buildProgram() {
|
|
|
527
528
|
program
|
|
528
529
|
.command('audio8-fetch-model [url]')
|
|
529
530
|
.description('下载 Audio8 TTS 模型(单独使用,不依赖 audio8 install)')
|
|
530
|
-
.
|
|
531
|
+
.option('--registration', '同时下载声音克隆注册子模型(约 +396MB,基础 TTS 不需要)')
|
|
532
|
+
.action(async (url, opts) => {
|
|
531
533
|
const mod = require('../tts/providers/audio8');
|
|
532
534
|
try {
|
|
533
|
-
process.exitCode = await mod.fetchModel({ url });
|
|
535
|
+
process.exitCode = await mod.fetchModel({ url, registration: !!opts.registration });
|
|
534
536
|
} catch (e) {
|
|
535
537
|
logger.error(e.message);
|
|
536
538
|
process.exitCode = 1;
|
package/tts/providers/audio8.js
CHANGED
|
@@ -471,66 +471,121 @@ async function status(opts) {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
module.exports = { synthesize, checkDeps, VOICES, DEFAULT_BASE_URL, install, uninstall, status, fetchModel };
|
|
474
|
+
module.exports = { synthesize, checkDeps, VOICES, DEFAULT_BASE_URL, install, uninstall, status, fetchModel, downloadTo };
|
|
475
475
|
|
|
476
476
|
// === fetchModel: 单独下载 Audio8 TTS 模型 ===
|
|
477
|
-
//
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
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 不需要
|
|
481
488
|
const MODEL_FILES = [
|
|
482
|
-
'
|
|
483
|
-
'
|
|
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'
|
|
484
504
|
];
|
|
485
505
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
506
|
+
// 下载单文件到 target。HF 风格 /resolve/ 会 301/302/307/308 跳 CDN,
|
|
507
|
+
// Node 的 http.get 不自动跟随重定向,必须手动跳(最多 5 跳)。
|
|
508
|
+
function downloadTo(url, target, file) {
|
|
489
509
|
return new Promise((resolve, reject) => {
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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);
|
|
503
544
|
});
|
|
504
545
|
}
|
|
505
546
|
|
|
506
547
|
async function fetchModel(opts) {
|
|
507
548
|
opts = opts || {};
|
|
508
|
-
|
|
509
|
-
const
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
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 });
|
|
518
559
|
|
|
519
560
|
let ok = 0, fail = 0;
|
|
520
|
-
for (const f of
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
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 {
|
|
527
580
|
fail++;
|
|
581
|
+
logger.error(` ✗ ${f} 所有源均失败: ${lastErr ? lastErr.message : '未知错误'}`);
|
|
528
582
|
}
|
|
529
583
|
}
|
|
530
584
|
if (fail > 0) {
|
|
531
|
-
|
|
585
|
+
logger.error(`失败 ${fail} 个文件,模型不完整。可换源自试: adoremix audio8-fetch-model <url>/`);
|
|
532
586
|
return 1;
|
|
533
587
|
}
|
|
534
|
-
|
|
588
|
+
logger.ok(`Audio8 模型就绪(${ok} 个文件): ${targetDir}`);
|
|
589
|
+
logger.log('重启服务生效: systemctl restart audio8-tts');
|
|
535
590
|
return 0;
|
|
536
591
|
}
|