@oxiaom/adoremix 1.0.58 → 1.0.59

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxiaom/adoremix",
3
- "version": "1.0.58",
3
+ "version": "1.0.59",
4
4
  "description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
5
5
  "bin": {
6
6
  "adoremix": "./bin/adoremix.js"
@@ -319,8 +319,21 @@ function install(opts) {
319
319
  if (fs.existsSync(BUNDLED_TARBALL)) {
320
320
  try {
321
321
  logger.log('=== 使用主包内置 Audio8_TTS tarball(离线) ===');
322
- execSync(`rm -rf ~/audio8 && mkdir -p ~/audio8 && tar xzf "${BUNDLED_TARBALL}" --strip-components=1 -C ~/audio8 && ls ~/audio8 | head -3`, { stdio: 'inherit', shell: '/bin/bash' });
323
- cloned = true;
322
+ // tarball 可能带 1~2 层包装目录(如 audio8src/Audio8_TTS-master/)。
323
+ // 不用 --strip-components(层数不定),解压后在 ~/audio8 里循环平仓:
324
+ // 只要目录下只有一个子目录且还看不到 onnx_runtime/,就把子目录内容上提,最多 3 层。
325
+ execSync(`rm -rf ~/audio8 && mkdir -p ~/audio8 && tar xzf "${BUNDLED_TARBALL}" -C ~/audio8 && ` +
326
+ `cd ~/audio8 && for i in 1 2 3; do ` +
327
+ `[ -f onnx_runtime/requirements.txt ] && break; ` +
328
+ `single=$(ls -A | wc -l); [ "$single" = "1" ] || break; ` +
329
+ `d=$(ls -A); [ -d "$d" ] || break; ` +
330
+ `mv "$d"/* . 2>/dev/null; mv "$d"/.[!.]* . 2>/dev/null; rmdir "$d" 2>/dev/null || true; ` +
331
+ `done; ls ~/audio8 | head -5`, { stdio: 'inherit', shell: '/bin/bash' });
332
+ // 平仓后必须能看到 onnx_runtime/requirements.txt,否则视为解压失败
333
+ const flat = execSync('[ -f ~/audio8/onnx_runtime/requirements.txt ] && echo OK || echo MISSING',
334
+ { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
335
+ if (flat === 'OK') cloned = true;
336
+ else logger.warn('内置 tarball 解压后未找到 onnx_runtime/requirements.txt(目录层级异常)');
324
337
  } catch (e) {
325
338
  logger.warn('内置 tarball 解压失败:' + e.message);
326
339
  }
@@ -365,16 +378,38 @@ function install(opts) {
365
378
  logger.warn('解决:手动在 ~/audio8 下放好 Audio8_TTS 源码再重试 install');
366
379
  return 1;
367
380
  }
381
+ // 统一校验目录结构(git clone 路径也可能带包装目录)
382
+ const layoutOk = execSync('[ -f ~/audio8/onnx_runtime/requirements.txt ] && echo OK || echo MISSING',
383
+ { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
384
+ if (layoutOk !== 'OK') {
385
+ logger.error('~/audio8 目录结构异常:未找到 onnx_runtime/requirements.txt(可能多了包装目录)');
386
+ logger.log('当前内容: ' + execSync('ls ~/audio8', { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim().replace(/\n/g, ' '));
387
+ return 1;
388
+ }
368
389
 
369
390
  // venv + pip install(Python 3.11+,numpy 2.4.3 需要)
391
+ // venv 路径必须与 AUDIO8_VENV_DIR/buildSystemdUnit 一致(~/audio8/onnx_runtime/.venv),
392
+ // 否则 systemd ExecStart 指向不存在的解释器,服务起不来
370
393
  const pyBase = (function(){
371
394
  try { execSync('command -v python3.11 2>/dev/null', { shell: '/bin/bash', stdio: 'pipe' }); return 'python3.11'; }
372
395
  catch (e) { return 'python3'; }
373
396
  })();
397
+ const venvDir = AUDIO8_VENV_DIR.replace(/^~/, os.homedir());
374
398
  try {
375
399
  logger.log('=== 创建 venv 并安装 Python 依赖(首次需 5-10 分钟下载 torch 等,Python=' + pyBase + ')===');
376
- execSync(`${pyBase} -m venv ~/.audio8_venv`, { stdio: 'inherit', shell: '/bin/bash' });
377
- execSync(`source ~/.audio8_venv/bin/activate && pip install -U pip --quiet && pip install -r ~/audio8/onnx_runtime/requirements.txt --quiet`, { stdio: 'inherit', shell: '/bin/bash' });
400
+ execSync(`${pyBase} -m venv ${venvDir}`, { stdio: 'inherit', shell: '/bin/bash' });
401
+ // torch 等大包走清华镜像(国内/公司网下官方 PyPI 常超时),失败再回退官方源。
402
+ // requirements.txt 缺 tokenizers(Audio8 运行需要),补装。
403
+ const pipCmd = (idx) =>
404
+ `source ${venvDir}/bin/activate && pip install -U pip --quiet && ` +
405
+ `pip install -r ~/audio8/onnx_runtime/requirements.txt --quiet ${idx} && ` +
406
+ `pip install tokenizers --quiet ${idx}`;
407
+ try {
408
+ execSync(pipCmd('--index-url https://pypi.tuna.tsinghua.edu.cn/simple'), { stdio: 'inherit', shell: '/bin/bash' });
409
+ } catch (e) {
410
+ logger.warn('清华镜像安装失败,回退官方 PyPI 重试: ' + String(e.message).slice(0, 150));
411
+ execSync(pipCmd(''), { stdio: 'inherit', shell: '/bin/bash' });
412
+ }
378
413
  } catch (e) {
379
414
  logger.error('Python 依赖安装失败: ' + e.message.slice(0, 200));
380
415
  return 1;
@@ -391,8 +426,12 @@ function install(opts) {
391
426
  return 1;
392
427
  }
393
428
 
394
- // 等服务健康(含下载 572MB 模型,冷启动最多 60s)
395
- logger.log('=== 等待服务健康(首次启动要下载 ~572MB 模型,最多 60 秒)===');
429
+ // 等服务健康(模型单独用 audio8-fetch-model 下载,未下模型时服务起不来是预期)
430
+ const modelReady = fs.existsSync(path.join(os.homedir(), 'audio8', 'onnx_runtime', 'model', 'runtime_manifest.json'));
431
+ if (!modelReady) {
432
+ logger.warn('模型未下载(' + (cloned ? '正常,模型与 install 解耦' : '') + '): 先执行 adoremix audio8-fetch-model 下载 ~423MB 模型,再 systemctl restart ' + AUDIO8_SYSTEMD_NAME);
433
+ }
434
+ logger.log('=== 等待服务健康(最多 60 秒)===');
396
435
  let ok = false;
397
436
  for (let i = 1; i <= 30; i++) {
398
437
  try {
@@ -404,8 +443,8 @@ function install(opts) {
404
443
  execSync('sleep 2', { stdio: 'pipe', shell: '/bin/bash' });
405
444
  }
406
445
  if (!ok) {
407
- logger.warn('60 秒内未就绪,请手动 systemctl status ' + AUDIO8_SYSTEMD_NAME);
408
- logger.log('也可直接前台启动测试: source ~/.audio8_venv/bin/activate && python -m arktts_runtime.service --model-dir ~/audio8/model --voices-dir ~/audio8/model/voices --port ' + AUDIO8_DEFAULT_PORT);
446
+ logger.warn('60 秒内未就绪: ' + (modelReady ? '请手动 systemctl status ' + AUDIO8_SYSTEMD_NAME : '模型缺失所致,先跑 adoremix audio8-fetch-model'));
447
+ logger.log('前台排查: cd ~/audio8/onnx_runtime && .venv/bin/' + pyBase + ' -m arktts_runtime.service --model-dir ./model --voices-dir ./model/voices --port ' + AUDIO8_DEFAULT_PORT);
409
448
  }
410
449
 
411
450
  // 改本地 config.ini
@@ -432,7 +471,7 @@ function uninstall(opts) {
432
471
  execSync(`systemctl --now disable ${AUDIO8_SYSTEMD_NAME} 2>/dev/null; true`, { stdio: 'pipe', shell: '/bin/bash' });
433
472
  execSync(`systemctl stop ${AUDIO8_SYSTEMD_NAME} 2>/dev/null; true`, { stdio: 'pipe', shell: '/bin/bash' });
434
473
  execSync(`rm -f ${AUDIO8_SYSTEMD_PATH} && systemctl daemon-reload`, { stdio: 'pipe', shell: '/bin/bash' });
435
- execSync(`rm -rf ~/audio8 ~/audio8_venv`, { stdio: 'pipe', shell: '/bin/bash' });
474
+ execSync(`rm -rf ~/audio8 ~/audio8_venv ~/.audio8_venv`, { stdio: 'pipe', shell: '/bin/bash' });
436
475
  execSync(`rm -rf ~/.cache/huggingface/hub/models--Audio8*`, { stdio: 'pipe', shell: '/bin/bash' });
437
476
  } catch (e) {
438
477
  logger.warn('uninstall 清理部分出错: ' + e.message);