@oxiaom/adoremix 1.0.96 → 1.0.98

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.96",
3
+ "version": "1.0.98",
4
4
  "description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
5
5
  "bin": {
6
6
  "adoremix": "./bin/adoremix.js"
package/src/cli.js CHANGED
@@ -40,14 +40,18 @@ function buildProgram() {
40
40
  .description('健康检查:node 版本、二进制、缺库、config.ini、.Adore.db、服务状态')
41
41
  .option('--workdir <path>')
42
42
  .option('--fix', '自动 apt install 缺的库(需要 root / sudo)')
43
+ .option('--fix-no-model', '配合 --fix:跳过 Audio8 模型下载(~423MB),只修其它项')
43
44
  .action((opts) => {
44
45
  const doctor = require('./doctor');
45
- process.exitCode = doctor.runDoctor(resolveWorkdir(opts.workdir), { fix: !!opts.fix });
46
+ process.exitCode = doctor.runDoctor(resolveWorkdir(opts.workdir), {
47
+ fix: !!opts.fix,
48
+ fixNoModel: !!opts.fixNoModel
49
+ });
46
50
  });
47
51
 
48
52
  const ttsCmd = program
49
53
  .command('tts')
50
- .description('TTS 文字转语音(支持 xf 讯飞 / minimax / edge 三种 provider)');
54
+ .description('TTS 文字转语音(支持 xf 讯飞 / minimax / edge / audio8 四种 provider)');
51
55
 
52
56
  ttsCmd
53
57
  .command('list')
@@ -18,7 +18,21 @@ module.exports = {
18
18
  DataPort: 6002,
19
19
  EnableRedis: false,
20
20
  // 设备静默多久判定离线(秒):局域网 12~15,公网 20~30
21
+ // 仅 DevOfflineMode=app 时有效
21
22
  DevOfflineTimeout: 25,
23
+ // 离线判定方式:
24
+ // tcp —— 只看 TCP 状态,socket 断开才算离线(**默认**)。
25
+ // 弱网/大延迟链路下不会把正常在线的设备误踢。
26
+ // 代价:设备断电(没发 FIN)要等 TCP 超时才发现。
27
+ // app —— 应用层静默超时。TCP 半开(断电没发 FIN)时也能发现,
28
+ // 但弱网链路会误踢。
29
+ // off —— 不做主动判定,只在 socket 真断开时下线。
30
+ DevOfflineMode: 'tcp',
31
+ // 是否主动发心跳帧:on(默认)/ off
32
+ // 关掉后如果 DevOfflineMode 还是 app,设备会被静默超时踢掉
33
+ DevHeartbeatSend: 'on',
34
+ // 心跳内容:okok / jxxx / alt(交替,兼容新旧固件)
35
+ DevHeartbeatMode: 'alt',
22
36
  LocalIP: '127.0.0.1',
23
37
  ManagePort: 6007,
24
38
  Netcross_Port0: 6000,
@@ -51,7 +51,15 @@ async function ensureConfig(workdir, opts) {
51
51
  logger.log('提示:可直接回车使用默认值;密码类项回车留空。');
52
52
  logger.log('');
53
53
  const answers = await wizard.run(merged.Settings || {});
54
- merged.Settings = Object.assign({}, merged.Settings, answers);
54
+ // 向导可能返回 TTS 段(provider 选择的结果)—— 那要并到 [TTS],
55
+ // 不能整个塞进 [Settings](会变成 Settings.TTS.provider,读配置时找不到)。
56
+ const ttsAnswers = answers.TTS;
57
+ const settingsAnswers = Object.assign({}, answers);
58
+ delete settingsAnswers.TTS;
59
+ merged.Settings = Object.assign({}, merged.Settings, settingsAnswers);
60
+ if (ttsAnswers && typeof ttsAnswers === 'object') {
61
+ merged.TTS = Object.assign({}, merged.TTS || {}, ttsAnswers);
62
+ }
55
63
  }
56
64
  // 端口系列:--port-series 117 → 所有端口都用 117xx
57
65
  if (opts.portSeries !== undefined && opts.portSeries !== null && opts.portSeries !== '') {
@@ -74,25 +74,43 @@ const QUESTIONS = [
74
74
  message: 'Redis 密码(无可留空)'
75
75
  },
76
76
  {
77
- type: 'confirm',
78
- name: '_enableTTS',
79
- message: '启用讯飞 TTS?',
80
- initial: true
77
+ type: 'select',
78
+ name: '_ttsProvider',
79
+ message: '选择 TTS provider',
80
+ choices: [
81
+ { title: 'edge Edge TTS(免费,需 python3 + edge-tts)', value: 'edge' },
82
+ { title: 'audio8 本地离线 TTS(免费自部署,需 Audio8 服务)', value: 'audio8' },
83
+ { title: 'xf 讯飞(商用,约 4000 元/年)', value: 'xf' },
84
+ { title: 'minimax MiniMax(包月几十元)', value: 'minimax' },
85
+ { title: '暂不配置 TTS', value: 'none' }
86
+ ],
87
+ initial: 0
81
88
  },
82
89
  {
83
- type: (prev) => prev ? 'text' : null,
90
+ type: (prev, values) => values._ttsProvider === 'xf' ? 'text' : null,
84
91
  name: 'ttsxfAPPID',
85
92
  message: '讯飞 APPID'
86
93
  },
87
94
  {
88
- type: (prev, values) => values._enableTTS ? 'text' : null,
95
+ type: (prev, values) => values._ttsProvider === 'xf' ? 'text' : null,
89
96
  name: 'ttsxfAPISecret',
90
97
  message: '讯飞 APISecret'
91
98
  },
92
99
  {
93
- type: (prev, values) => values._enableTTS ? 'text' : null,
100
+ type: (prev, values) => values._ttsProvider === 'xf' ? 'text' : null,
94
101
  name: 'ttsxfAPIKey',
95
102
  message: '讯飞 APIKey'
103
+ },
104
+ {
105
+ type: (prev, values) => values._ttsProvider === 'minimax' ? 'password' : null,
106
+ name: '_minimaxToken',
107
+ message: 'MiniMax API token'
108
+ },
109
+ {
110
+ type: (prev, values) => values._ttsProvider === 'audio8' ? 'text' : null,
111
+ name: '_audio8BaseUrl',
112
+ message: 'Audio8 服务地址(本机部署回车用默认,远程填对方 IP)',
113
+ initial: 'http://127.0.0.1:8024'
96
114
  }
97
115
  ];
98
116
 
@@ -118,6 +136,25 @@ async function run(current) {
118
136
  }
119
137
  }
120
138
  delete answers._enableTTS;
139
+
140
+ // 把 provider 选择翻译成 config.ini 的实际键。
141
+ //
142
+ // 向导只问一次「用哪个 provider」,但各家的凭证字段完全不同
143
+ // (讯飞在 [Settings]、minimax/audio8 在 [TTS]),所以这里做映射。
144
+ const provider = answers._ttsProvider;
145
+ if (provider && provider !== 'none') {
146
+ answers.TTS = answers.TTS || {};
147
+ answers.TTS.provider = provider;
148
+ if (provider === 'minimax' && answers._minimaxToken) {
149
+ answers.TTS.minimax_token = answers._minimaxToken;
150
+ }
151
+ if (provider === 'audio8' && answers._audio8BaseUrl) {
152
+ answers.TTS.audio8_base_url = answers._audio8BaseUrl;
153
+ }
154
+ }
155
+ delete answers._ttsProvider;
156
+ delete answers._minimaxToken;
157
+ delete answers._audio8BaseUrl;
121
158
  return answers;
122
159
  }
123
160
 
@@ -12,7 +12,13 @@
12
12
  * 6. 内存余量(模型常驻 ~1.8GB,<2GB 可用会 OOM)
13
13
  * 7. 磁盘余量(模型 423MB + 源码 venv ~500MB,<1GB 告警)
14
14
  *
15
- * --fix 行为:服务未 active → restart;模型缺失 → 提示跑 audio8-fetch-model(不自动下 423MB)。
15
+ * --fix 行为:
16
+ * - 服务未 active → systemctl restart
17
+ * - 未开机自启 → systemctl enable
18
+ * - venv 缺 pip 包 → pip install(onnxruntime 还会自动降到 <1.24)
19
+ * - 默认音色缺失 → 调 fetch-model 的 seed 逻辑补音色(模型已在,几秒)
20
+ * - 模型缺失 → **自动下载**(~423MB)。加 --fix-no-model 可跳过
21
+ * - ffmpeg 缺失 → 装系统包(apt/dnf/apk/pacman)
16
22
  */
17
23
 
18
24
  const { execSync } = require('child_process');
@@ -61,6 +67,71 @@ function isInstalled() {
61
67
  return fs.existsSync(UNIT_PATH) || fs.existsSync(paths().runtime);
62
68
  }
63
69
 
70
+ // ---------------------------------------------------------------------------
71
+ // 自动修复用的动作
72
+ //
73
+ // 设计原则:**能自动修的就修,修不了的要说清楚下一步跑什么**。
74
+ // 之前 --fix 只会重启服务,其余全是"提示用户自己去跑某命令",
75
+ // 装完 audio8 的用户还是得手动敲 3~4 条命令才能用起来。
76
+ // ---------------------------------------------------------------------------
77
+
78
+ // pip 装包(venv 里)
79
+ function pipInstall(venvPy, spec) {
80
+ return execSync(`"${venvPy}" -m pip install ${spec}`, {
81
+ shell: '/bin/bash',
82
+ encoding: 'utf8',
83
+ stdio: ['pipe', 'pipe', 'pipe']
84
+ });
85
+ }
86
+
87
+ // 装系统包(ffmpeg 之类)
88
+ function detectPkgMgr() {
89
+ for (const [cmd, args] of [['apt-get', 'apt-get install -y'], ['dnf', 'dnf install -y'],
90
+ ['yum', 'yum install -y'], ['apk', 'apk add --no-cache'],
91
+ ['pacman', 'pacman -S --noconfirm']]) {
92
+ if (sh(`command -v ${cmd} 2>/dev/null`)) return args;
93
+ }
94
+ return null;
95
+ }
96
+
97
+ function installSystemPkg(pkg) {
98
+ const mgr = detectPkgMgr();
99
+ if (!mgr) return { ok: false, msg: '没找到包管理器(apt/dnf/yum/apk/pacman),请手工装 ' + pkg };
100
+ try {
101
+ execSync(`${mgr} ${pkg}`, { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] });
102
+ return { ok: true };
103
+ } catch (e) {
104
+ return { ok: false, msg: (e.message || '').split('\n')[0] };
105
+ }
106
+ }
107
+
108
+ // ffmpeg 在不在(Audio8 服务端只返 WAV,provider 层要转 mp3)
109
+ function hasFfmpeg() {
110
+ return !!sh('command -v ffmpeg 2>/dev/null');
111
+ }
112
+
113
+ // 跑 adoremix audio8-fetch-model(同步)
114
+ //
115
+ // fetchModel 是 async 的,而 doctor 是同步函数 —— 直接 await 不了,
116
+ // 异步调用的结果会在 doctor 退出后丢(下载刚开始进程就退了)。
117
+ // 所以用子进程跑 CLI,等它真跑完。
118
+ function runFetchModel() {
119
+ const cliJs = path.join(__dirname, '..', 'bin', 'adoremix.js');
120
+ try {
121
+ execSync(`node "${cliJs}" audio8-fetch-model`, {
122
+ shell: '/bin/bash',
123
+ encoding: 'utf8',
124
+ stdio: ['pipe', 'pipe', 'pipe'],
125
+ timeout: 30 * 60 * 1000 // 423MB,给 30 分钟
126
+ });
127
+ return { ok: true };
128
+ } catch (e) {
129
+ const out = `${(e.stdout || '').toString()}\n${(e.stderr || '').toString()}`;
130
+ const line = out.split('\n').filter(l => l.trim()).pop() || (e.message || '').split('\n')[0];
131
+ return { ok: false, msg: String(line).slice(0, 200) };
132
+ }
133
+ }
134
+
64
135
  // 内存(MB):/proc/meminfo MemAvailable
65
136
  function memAvailableMB() {
66
137
  try {
@@ -93,7 +164,18 @@ function checkAudio8Deployment(issues, opts) {
93
164
  logger.ok(`✓ systemd 单元已注册(开机自启)`);
94
165
  } else {
95
166
  issues.push({ type: 'audio8-unit', severity: 'warn', msg: `audio8-tts 未 enabled(状态 ${enabled}),重启后不会自动拉起` });
96
- logger.warn(`⚠ audio8-tts 未开机自启(${enabled}):systemctl enable ${UNIT_NAME}`);
167
+ logger.warn(`⚠ audio8-tts 未开机自启(${enabled})`);
168
+ if (opts.fix) {
169
+ logger.info(`==> 自动修复:systemctl enable ${UNIT_NAME}`);
170
+ try {
171
+ execSync(`systemctl enable ${UNIT_NAME}`, { stdio: 'inherit' });
172
+ logger.ok('✓ 已设为开机自启');
173
+ } catch (e) {
174
+ logger.error(`开机自启设置失败:${(e.message || '').split('\n')[0]}`);
175
+ }
176
+ } else {
177
+ logger.log(` 修复:systemctl enable ${UNIT_NAME}(或 doctor --fix 自动设置)`);
178
+ }
97
179
  }
98
180
  const active = sh(`systemctl is-active ${UNIT_NAME} 2>/dev/null`) || 'unknown';
99
181
  if (active !== 'active') {
@@ -124,28 +206,78 @@ function checkAudio8Deployment(issues, opts) {
124
206
  if (!ortVer) {
125
207
  issues.push({ type: 'audio8-venv', severity: 'error', msg: `venv 缺 onnxruntime(重跑 adoremix audio8 install)` });
126
208
  logger.error(`❌ venv 缺 onnxruntime`);
209
+ if (opts.fix) {
210
+ logger.info('==> 自动修复:pip install "onnxruntime>=1.22,<1.24"');
211
+ try {
212
+ pipInstall(p.venvPy, '"onnxruntime>=1.22,<1.24"');
213
+ logger.ok('✓ onnxruntime 已安装');
214
+ } catch (e) {
215
+ logger.error(`安装失败:${(e.message || '').split('\n')[0]}`);
216
+ }
217
+ }
127
218
  } else if (parseInt(ortVer.split('.')[1] || '0', 10) >= 24) {
128
219
  // 0.1B runtime 要求 onnxruntime <1.24
129
220
  issues.push({ type: 'audio8-venv', severity: 'error', msg: `onnxruntime ${ortVer} 太新(0.1B runtime 要求 <1.24)。修复:${p.venvPy} -m pip install "onnxruntime>=1.22,<1.24"` });
130
221
  logger.error(`❌ onnxruntime ${ortVer}(要求 <1.24)`);
222
+ if (opts.fix) {
223
+ // 自动降级 —— 这个不修的话服务根本起不来
224
+ logger.info('==> 自动修复:降级 onnxruntime 到 <1.24');
225
+ try {
226
+ pipInstall(p.venvPy, '"onnxruntime>=1.22,<1.24"');
227
+ logger.ok('✓ onnxruntime 已降到 <1.24');
228
+ } catch (e) {
229
+ logger.error(`降级失败:${(e.message || '').split('\n')[0]}`);
230
+ }
231
+ }
131
232
  } else {
132
233
  logger.ok(`✓ venv 就绪(onnxruntime ${ortVer}${tokVer ? `, tokenizers ${tokVer}` : ''})`);
133
234
  }
134
235
  if (ortVer && !tokVer) {
135
236
  issues.push({ type: 'audio8-venv', severity: 'error', msg: `venv 缺 tokenizers。修复:${p.venvPy} -m pip install "tokenizers>=0.20,<0.23"` });
136
237
  logger.error(`❌ venv 缺 tokenizers`);
238
+ if (opts.fix) {
239
+ logger.info('==> 自动修复:pip install "tokenizers>=0.20,<0.23"');
240
+ try {
241
+ pipInstall(p.venvPy, '"tokenizers>=0.20,<0.23"');
242
+ logger.ok('✓ tokenizers 已安装');
243
+ } catch (e) {
244
+ logger.error(`安装失败:${(e.message || '').split('\n')[0]}`);
245
+ }
246
+ }
137
247
  }
138
248
  }
139
249
 
140
250
  // ---- 3. 模型核心文件 ----
141
251
  const missingFiles = MODEL_CORE_FILES.filter(f => !fs.existsSync(path.join(p.model, f)));
252
+ let modelReady = false;
142
253
  if (missingFiles.length === MODEL_CORE_FILES.length) {
143
254
  issues.push({ type: 'audio8-model', severity: 'error', msg: `模型未下载:${p.model}。执行 adoremix audio8-fetch-model(~423MB),或自托管后 adoremix audio8-fetch-model <url>` });
144
- logger.error(`❌ 模型未下载:adoremix audio8-fetch-model`);
255
+ logger.error(`❌ 模型未下载`);
256
+ if (opts.fix && !opts.fixNoModel) {
257
+ // 模型是最大的一块(~423MB),但自动装 audio8 的场景里,
258
+ // 没模型 = 服务起不来 = 白装。默认直接下。
259
+ logger.info('==> 自动修复:下载模型(~423MB,需要几分钟)');
260
+ const r = runFetchModel();
261
+ if (r.ok) logger.ok('✓ 模型下载完成');
262
+ else logger.error(`模型下载失败:${r.msg}`);
263
+ } else if (opts.fix && opts.fixNoModel) {
264
+ logger.log(' 跳过模型下载(--fix-no-model),请手工跑 adoremix audio8-fetch-model');
265
+ } else {
266
+ logger.log(' 修复:adoremix audio8-fetch-model(~423MB)或 doctor --fix 自动下载');
267
+ }
145
268
  } else if (missingFiles.length > 0) {
146
269
  issues.push({ type: 'audio8-model', severity: 'error', msg: `模型不完整,缺 ${missingFiles.length} 个文件:${missingFiles.slice(0, 3).join(', ')}${missingFiles.length > 3 ? ' 等' : ''}。重跑 adoremix audio8-fetch-model` });
147
- logger.error(`❌ 模型不完整(缺 ${missingFiles.length} 个文件),重跑 adoremix audio8-fetch-model`);
270
+ logger.error(`❌ 模型不完整(缺 ${missingFiles.length} 个文件)`);
271
+ if (opts.fix && !opts.fixNoModel) {
272
+ logger.info('==> 自动修复:补齐缺失的模型文件');
273
+ const r = runFetchModel();
274
+ if (r.ok) logger.ok('✓ 模型已补齐');
275
+ else logger.error(`模型下载失败:${r.msg}`);
276
+ } else {
277
+ logger.log(' 修复:adoremix audio8-fetch-model');
278
+ }
148
279
  } else {
280
+ modelReady = true;
149
281
  let modelMB = null;
150
282
  try { modelMB = Math.round(parseInt(sh(`du -sm "${p.model}" | cut -f1`), 10)); } catch (e) {}
151
283
  logger.ok(`✓ 模型完整(${p.model}${modelMB ? `, ~${modelMB}MB` : ''})`);
@@ -154,10 +286,19 @@ function checkAudio8Deployment(issues, opts) {
154
286
  // ---- 4. 默认音色 ----
155
287
  if (fs.existsSync(p.defaultVoiceMeta)) {
156
288
  logger.ok(`✓ 默认音色 default`);
157
- } else if (missingFiles.length === 0) {
289
+ } else if (modelReady) {
158
290
  // 模型在但音色缺(旧版本 fetch-model 不会自动 seed)
159
291
  issues.push({ type: 'audio8-voice', severity: 'warn', msg: `默认音色缺失:${p.defaultVoiceMeta}。重跑 adoremix audio8-fetch-model(已有模型文件会秒过,仅补 seed)` });
160
- logger.warn(`⚠ 默认音色 default 缺失,重跑 adoremix audio8-fetch-model 自动补`);
292
+ logger.warn(`⚠ 默认音色 default 缺失`);
293
+ if (opts.fix) {
294
+ // 模型已在,重新跑 fetch-model 会秒过(只补音色,不重复下 423MB)
295
+ logger.info('==> 自动修复:补默认音色(模型已在,很快)');
296
+ const r = runFetchModel();
297
+ if (r.ok) logger.ok('✓ 默认音色已补齐');
298
+ else logger.error(`补音色失败:${r.msg}`);
299
+ } else {
300
+ logger.log(' 修复:adoremix audio8-fetch-model(自动补)');
301
+ }
161
302
  }
162
303
 
163
304
  // ---- 5. 健康探测(服务 active 时才查)----
@@ -186,7 +327,25 @@ function checkAudio8Deployment(issues, opts) {
186
327
  }
187
328
  }
188
329
 
189
- // ---- 7. 磁盘余量 ----
330
+ // ---- 7. ffmpeg(provider 层 WAV→MP3 转码用)----
331
+ // Audio8 服务端只返回 WAV,AdoreMix 必须靠 ffmpeg 转成 mp3 才能推给设备。
332
+ // 缺 ffmpeg 的话合成会失败,但报错在 TTS 层,现场很难联想到是这个。
333
+ if (!hasFfmpeg()) {
334
+ issues.push({ type: 'audio8-ffmpeg', severity: 'error', msg: `缺 ffmpeg(Audio8 返回 WAV,AdoreMix 需要它转 mp3)。修复:装 ffmpeg` });
335
+ logger.error('❌ 缺 ffmpeg(Audio8 需要它做 WAV→MP3 转码)');
336
+ if (opts.fix) {
337
+ logger.info('==> 自动修复:安装 ffmpeg');
338
+ const r = installSystemPkg('ffmpeg');
339
+ if (r.ok) logger.ok('✓ ffmpeg 已安装');
340
+ else logger.error(`安装失败:${r.msg}`);
341
+ } else {
342
+ logger.log(' 修复:apt install ffmpeg(或 doctor --fix 自动装)');
343
+ }
344
+ } else {
345
+ logger.ok('✓ ffmpeg 就绪');
346
+ }
347
+
348
+ // ---- 8. 磁盘余量 ----
190
349
  const diskMB = fs.existsSync(p.runtime) ? diskFreeMB(p.runtime) : null;
191
350
  if (diskMB !== null && diskMB < 1024) {
192
351
  issues.push({ type: 'audio8-disk', severity: 'warn', msg: `磁盘可用 ${diskMB}MB 不足 1GB(模型 423MB + venv ~500MB)` });
package/src/doctor.js CHANGED
@@ -466,15 +466,44 @@ function runDoctor(workdir, opts) {
466
466
  }
467
467
  }
468
468
 
469
- // 9. Audio8 本机部署体检(Linux + 本机装了 audio8 或 provider=audio8 且指向本机时)
469
+ // 9. Audio8 部署体检
470
+ //
471
+ // 分两种情况:
472
+ // - provider=audio8 且指向本机 → 查本机部署(systemd/venv/模型/音色)
473
+ // - provider=audio8 且指向远程 → 查远程可达性(第 8 节已查,这里补充说明)
474
+ // - 本机装了 audio8 但当前不是这个 provider → 也体检一下(提前发现问题)
470
475
  if (process.platform === 'linux') {
471
476
  const a8 = require('./doctor-audio8');
472
477
  const audio8BaseUrl = (cfgObj.TTS && cfgObj.TTS.audio8_base_url) || 'http://127.0.0.1:8024';
473
- const isLocalProvider = providerName === 'audio8' && /^https?:\/\/(127\.0\.0\.1|localhost)(:|\/|$)/.test(audio8BaseUrl);
478
+ const isAudio8 = providerName === 'audio8';
479
+ const isLocalProvider = isAudio8 && /^https?:\/\/(127\.0\.0\.1|localhost)(:|\/|$)/.test(audio8BaseUrl);
480
+
474
481
  if (isLocalProvider || a8.isInstalled()) {
475
482
  logger.log('');
476
483
  logger.log('=== Audio8 本机部署检查 ===');
477
- a8.checkAudio8Deployment(issues, { fix: !!opts.fix, providerActive: isLocalProvider });
484
+ a8.checkAudio8Deployment(issues, {
485
+ fix: !!opts.fix,
486
+ fixNoModel: !!opts.fixNoModel,
487
+ providerActive: isLocalProvider
488
+ });
489
+ } else if (isAudio8) {
490
+ // provider=audio8 但指向远程 —— 本机不该有 systemd 单元,那是正常的。
491
+ // 但要提醒:远程部署必须显式配地址,否则会连到本机 8024(那里什么都没有)。
492
+ logger.log('');
493
+ logger.log('=== Audio8 检查(远程部署)===');
494
+ const defaultUrl = 'http://127.0.0.1:8024';
495
+ if (audio8BaseUrl === defaultUrl) {
496
+ issues.push({
497
+ type: 'audio8-remote',
498
+ severity: 'warn',
499
+ msg: `provider=audio8 但 audio8_base_url 还是默认的 ${defaultUrl}。如果 Audio8 装在别的机器上,必须改成对方地址(如 http://192.168.1.114:8024),否则合成时会连到本机 8024 端口(那里没有服务)`
500
+ });
501
+ logger.warn(`⚠ audio8_base_url 是默认的 ${defaultUrl}`);
502
+ logger.log(' 远程部署请改成:http://<Audio8所在机器IP>:8024');
503
+ logger.log(' 设置:adoremix config set TTS.audio8_base_url http://<IP>:8024');
504
+ } else {
505
+ logger.log(` Audio8 服务地址: ${audio8BaseUrl}(远程)`);
506
+ }
478
507
  }
479
508
  }
480
509
 
package/src/install.js CHANGED
@@ -51,7 +51,22 @@ function copyNative(native, workdir, force) {
51
51
  fse.copySync(native.root, workdir, {
52
52
  filter: (s) => {
53
53
  const base = path.basename(s);
54
- return base !== 'README.md' || path.dirname(s) !== native.root;
54
+ if (base === 'README.md' && path.dirname(s) === native.root) return false;
55
+ // **绝不覆盖客户自己的数据库**。
56
+ //
57
+ // native 目录里带了一份 .Adore.db(示例库)。不带 filter 的话,
58
+ // `adoremix install --force` 升级时会把客户现场正在用的库覆盖掉 ——
59
+ // 设备、计费、录音记录全丢。这是不可逆的数据损失。
60
+ //
61
+ // 只在目标目录**没有**库时才复制示例库过去。
62
+ if (base === '.Adore.db') {
63
+ const dst = path.join(workdir, '.Adore.db');
64
+ if (fs.existsSync(dst)) {
65
+ logger.warn('检测到工作目录已有 .Adore.db —— 保留客户现有数据库,不覆盖。');
66
+ return false;
67
+ }
68
+ }
69
+ return true;
55
70
  }
56
71
  });
57
72
  fs.writeFileSync(marker, JSON.stringify({
@@ -114,7 +129,7 @@ function installHelperDeps(workdir, skipNpmInstall) {
114
129
  }
115
130
  }
116
131
 
117
- // 部署多 provider TTS dispatcher(xf/minimax/edge)
132
+ // 部署多 provider TTS dispatcher(xf/minimax/edge/audio8)
118
133
  // 覆盖原 Dockerfile 拷的旧 tts.js(讯飞专用版),换成统一 dispatcher
119
134
  function deployTtsDispatcher(workdir) {
120
135
  const ttsSrcDir = path.join(__dirname, '..', 'tts');
@@ -135,7 +150,7 @@ function deployTtsDispatcher(workdir) {
135
150
  const wrapperSrc = path.join(ttsSrcDir, 'tts-wrapper.js');
136
151
  const ttsJs = path.join(workdir, 'tts.js');
137
152
  fse.copyFileSync(wrapperSrc, ttsJs);
138
- logger.ok('部署 TTS dispatcher(xf/minimax/edge 三选一)');
153
+ logger.ok('部署 TTS dispatcher(xf/minimax/edge/audio8 四选一)');
139
154
  logger.log(' 配置:adoremix tts config');
140
155
  logger.log(' 测试:adoremix tts test "你好"');
141
156
  }
package/src/tts-cli.js CHANGED
@@ -171,6 +171,33 @@ async function cmdConfig(workdir, opts) {
171
171
  logger.log('Edge TTS 是免费的,无需凭证。');
172
172
  logger.log('需要: python3 + edge-tts (pip) + ffmpeg');
173
173
  logger.log('检查: adoremix tts deps');
174
+ } else if (r1.provider === 'audio8') {
175
+ // Audio8 是本机/远程部署的 TTS 服务,没有 token,配置的是服务地址。
176
+ //
177
+ // 之前这个分支是空的 —— 选了 audio8 之后既不提示要装服务,
178
+ // 也不写 audio8_base_url,config.ini 里就只剩 provider=audio8,
179
+ // 合成时只能连默认的 127.0.0.1:8024(远程部署就连错了)。
180
+ const cur = c.TTS.audio8_base_url || 'http://127.0.0.1:8024';
181
+ const r = await prompts({
182
+ type: 'text',
183
+ name: 'v',
184
+ message: `Audio8 服务地址${cur ? '(回车保持当前)' : ''}`,
185
+ initial: cur
186
+ });
187
+ const url = (r.v && r.v.trim()) ? r.v.trim() : cur;
188
+ cfg.setConfigValue(workdir, 'TTS.audio8_base_url', url);
189
+ logger.ok(`TTS.audio8_base_url = ${url}`);
190
+
191
+ logger.log('');
192
+ logger.log('Audio8 需要先部署服务:');
193
+ if (process.platform === 'linux') {
194
+ logger.log(' 本机部署: adoremix audio8 install && adoremix audio8-fetch-model');
195
+ } else {
196
+ logger.log(' 本机部署仅 Linux 支持(依赖 systemd)。');
197
+ logger.log(' Windows/macOS 请部署到 Linux 主机后,用上面的地址远程调用。');
198
+ }
199
+ logger.log(' 检查服务: adoremix audio8 status');
200
+ logger.log(' 依赖检查: adoremix tts deps');
174
201
  }
175
202
 
176
203
  logger.log('');
@@ -532,7 +532,7 @@ async function status(opts) {
532
532
  }
533
533
  }
534
534
 
535
- module.exports = { synthesize, checkDeps, VOICES, DEFAULT_BASE_URL, install, uninstall, status, fetchModel, downloadTo };
535
+ module.exports = { synthesize, checkDeps, VOICES, voices: VOICES, DEFAULT_BASE_URL, install, uninstall, status, fetchModel, downloadTo };
536
536
 
537
537
  // === fetchModel: 单独下载 Audio8 TTS 模型 ===
538
538
  // 源优先级:环境变量/参数指定 > hf-mirror.com(国内可达) > huggingface.co(官方,国内常被墙)
package/tts/tts.js CHANGED
@@ -58,7 +58,7 @@ async function main() {
58
58
  const providerName = (ttsSection.provider || 'xf').toLowerCase();
59
59
  const provider = PROVIDERS[providerName];
60
60
  if (!provider) {
61
- err(`未知 provider: ${providerName}(可选: xf / minimax / edge)`);
61
+ err(`未知 provider: ${providerName}(可选: xf / minimax / edge / audio8)`);
62
62
  process.exit(3);
63
63
  }
64
64
 
@@ -75,7 +75,15 @@ async function main() {
75
75
  xf_apiKey: ttsSection.xf_apiKey || settings.ttsxfAPIKey || apiKeyArg || '',
76
76
  xf_voice_override: ttsSection.xf_voice_override || '',
77
77
  minimax_token: ttsSection.minimax_token || '',
78
- edge_voice_override: ttsSection.edge_voice_override || ''
78
+ edge_voice_override: ttsSection.edge_voice_override || '',
79
+ // Audio8 服务地址。
80
+ //
81
+ // 这个字段以前漏了 —— provider 侧读 creds.audio8_base_url,
82
+ // 拿不到就回退到内置默认 http://127.0.0.1:8024。
83
+ // 结果:本机部署碰巧能用,但**远程部署连错地址**(连自己的 8024
84
+ // 而不是配置里的局域网机器),而且 config.ini 里写了也不生效。
85
+ audio8_base_url: ttsSection.audio8_base_url || '',
86
+ audio8_voice_override: ttsSection.audio8_voice_override || ''
79
87
  };
80
88
 
81
89
  log(`provider=${providerName} voice=${voice} text=${text.length}字 → ${mp3Name}`);