@oxiaom/adoremix 1.0.61 → 1.0.63
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/doctor-audio8.js +199 -0
- package/src/doctor.js +12 -0
- package/src/tts-deps.js +12 -26
- package/tts/providers/audio8.js +18 -10
package/package.json
CHANGED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Audio8 本机部署体检(doctor 第 9 节)
|
|
5
|
+
*
|
|
6
|
+
* 检查项(与 v1.0.60+ 部署结构对齐):
|
|
7
|
+
* 1. systemd 单元存在 + enabled + active
|
|
8
|
+
* 2. venv 解释器存在 + 关键 pip 包(onnxruntime <1.24 / tokenizers)
|
|
9
|
+
* 3. 模型目录 + 核心文件(runtime_manifest.json 等)齐全
|
|
10
|
+
* 4. 默认音色(voices/default/{codes.npy,meta.json})
|
|
11
|
+
* 5. /api/health 健康探测
|
|
12
|
+
* 6. 内存余量(模型常驻 ~1.8GB,<2GB 可用会 OOM)
|
|
13
|
+
* 7. 磁盘余量(模型 423MB + 源码 venv ~500MB,<1GB 告警)
|
|
14
|
+
*
|
|
15
|
+
* --fix 行为:服务未 active → restart;模型缺失 → 提示跑 audio8-fetch-model(不自动下 423MB)。
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const { execSync } = require('child_process');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const os = require('os');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
const logger = require('./logger');
|
|
23
|
+
|
|
24
|
+
const RUNTIME_DIR = 'onnx_runtime_0_1b_int8';
|
|
25
|
+
const UNIT_NAME = 'audio8-tts';
|
|
26
|
+
const UNIT_PATH = `/etc/systemd/system/${UNIT_NAME}.service`;
|
|
27
|
+
const HEALTH_URL = 'http://127.0.0.1:8024/api/health';
|
|
28
|
+
|
|
29
|
+
const MODEL_CORE_FILES = [
|
|
30
|
+
'runtime_manifest.json',
|
|
31
|
+
'config.json',
|
|
32
|
+
'reference_codes.npy',
|
|
33
|
+
'codec_decoder_fp16.onnx',
|
|
34
|
+
'codec_decoder_fp16.onnx.data',
|
|
35
|
+
'slow_ar_int8.onnx',
|
|
36
|
+
'slow_ar_int8.onnx.data',
|
|
37
|
+
'fast_ar_int8.onnx',
|
|
38
|
+
'fast_ar_int8.onnx.data',
|
|
39
|
+
'tokenizer/tokenizer.json'
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
function paths() {
|
|
43
|
+
const home = os.homedir();
|
|
44
|
+
const runtime = path.join(home, 'audio8', RUNTIME_DIR);
|
|
45
|
+
return {
|
|
46
|
+
home,
|
|
47
|
+
runtime,
|
|
48
|
+
venvPy: path.join(runtime, '.venv', 'bin', 'python'),
|
|
49
|
+
model: path.join(runtime, 'model'),
|
|
50
|
+
defaultVoiceMeta: path.join(runtime, 'voices', 'default', 'meta.json')
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function sh(cmd) {
|
|
55
|
+
try {
|
|
56
|
+
return execSync(cmd, { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
57
|
+
} catch (e) { return null; }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function isInstalled() {
|
|
61
|
+
return fs.existsSync(UNIT_PATH) || fs.existsSync(paths().runtime);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 内存(MB):/proc/meminfo MemAvailable
|
|
65
|
+
function memAvailableMB() {
|
|
66
|
+
try {
|
|
67
|
+
const m = fs.readFileSync('/proc/meminfo', 'utf8').match(/MemAvailable:\s+(\d+)\s*kB/);
|
|
68
|
+
return m ? Math.round(parseInt(m[1], 10) / 1024) : null;
|
|
69
|
+
} catch (e) { return null; }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 磁盘(MB):runtime 所在挂载点可用空间
|
|
73
|
+
function diskFreeMB(dir) {
|
|
74
|
+
const out = sh(`df -Pm "${dir}" 2>/dev/null | awk 'NR==2 {print $4}'`);
|
|
75
|
+
const n = parseInt(out, 10);
|
|
76
|
+
return isNaN(n) ? null : n;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function checkAudio8Deployment(issues, opts) {
|
|
80
|
+
opts = opts || {};
|
|
81
|
+
const p = paths();
|
|
82
|
+
const providerActive = !!opts.providerActive;
|
|
83
|
+
|
|
84
|
+
// ---- 1. systemd 单元 ----
|
|
85
|
+
if (!fs.existsSync(UNIT_PATH)) {
|
|
86
|
+
const msg = `Audio8 systemd 单元不存在(${UNIT_PATH})。本机部署需 adoremix audio8 install;若改用远程 Audio8,请在 config.ini [TTS] audio8_base_url 配远程地址。`;
|
|
87
|
+
issues.push({ type: 'audio8-unit', severity: providerActive ? 'error' : 'warn', msg });
|
|
88
|
+
logger.error(`❌ ${msg}`);
|
|
89
|
+
return; // 单元都没有,后面查了也没意义
|
|
90
|
+
}
|
|
91
|
+
const enabled = sh(`systemctl is-enabled ${UNIT_NAME} 2>/dev/null`) || 'unknown';
|
|
92
|
+
if (enabled === 'enabled') {
|
|
93
|
+
logger.ok(`✓ systemd 单元已注册(开机自启)`);
|
|
94
|
+
} else {
|
|
95
|
+
issues.push({ type: 'audio8-unit', severity: 'warn', msg: `audio8-tts 未 enabled(状态 ${enabled}),重启后不会自动拉起` });
|
|
96
|
+
logger.warn(`⚠ audio8-tts 未开机自启(${enabled}):systemctl enable ${UNIT_NAME}`);
|
|
97
|
+
}
|
|
98
|
+
const active = sh(`systemctl is-active ${UNIT_NAME} 2>/dev/null`) || 'unknown';
|
|
99
|
+
if (active !== 'active') {
|
|
100
|
+
issues.push({ type: 'audio8-active', severity: providerActive ? 'error' : 'warn', msg: `audio8-tts 未运行(${active})。常见原因:模型未下载(adoremix audio8-fetch-model)或端口被占用。排查:journalctl -u ${UNIT_NAME} -n 30` });
|
|
101
|
+
logger.error(`❌ audio8-tts 未运行(${active})`);
|
|
102
|
+
if (opts.fix) {
|
|
103
|
+
logger.info(`==> 自动修复:systemctl restart ${UNIT_NAME}`);
|
|
104
|
+
try {
|
|
105
|
+
execSync(`systemctl restart ${UNIT_NAME}`, { stdio: 'inherit' });
|
|
106
|
+
logger.ok('✓ 已重启(模型冷启动加载约 20-30 秒,稍后再跑 doctor 确认健康)');
|
|
107
|
+
} catch (e) {
|
|
108
|
+
logger.error(`重启失败:${(e.message || '').split('\n')[0]},手动排查 journalctl -u ${UNIT_NAME} -n 30`);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
logger.log(` 修复:systemctl restart ${UNIT_NAME}(或 doctor --fix 自动重启)`);
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
logger.ok(`✓ audio8-tts 运行中`);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ---- 2. venv + 关键 pip 包 ----
|
|
118
|
+
if (!fs.existsSync(p.venvPy)) {
|
|
119
|
+
issues.push({ type: 'audio8-venv', severity: 'error', msg: `venv 解释器缺失:${p.venvPy}(重跑 adoremix audio8 install)` });
|
|
120
|
+
logger.error(`❌ venv 缺失:${p.venvPy}`);
|
|
121
|
+
} else {
|
|
122
|
+
const ortVer = sh(`"${p.venvPy}" -c "import onnxruntime; print(onnxruntime.__version__)" 2>/dev/null`);
|
|
123
|
+
const tokVer = sh(`"${p.venvPy}" -c "import tokenizers; print(tokenizers.__version__)" 2>/dev/null`);
|
|
124
|
+
if (!ortVer) {
|
|
125
|
+
issues.push({ type: 'audio8-venv', severity: 'error', msg: `venv 缺 onnxruntime(重跑 adoremix audio8 install)` });
|
|
126
|
+
logger.error(`❌ venv 缺 onnxruntime`);
|
|
127
|
+
} else if (parseInt(ortVer.split('.')[1] || '0', 10) >= 24) {
|
|
128
|
+
// 0.1B runtime 要求 onnxruntime <1.24
|
|
129
|
+
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
|
+
logger.error(`❌ onnxruntime ${ortVer}(要求 <1.24)`);
|
|
131
|
+
} else {
|
|
132
|
+
logger.ok(`✓ venv 就绪(onnxruntime ${ortVer}${tokVer ? `, tokenizers ${tokVer}` : ''})`);
|
|
133
|
+
}
|
|
134
|
+
if (ortVer && !tokVer) {
|
|
135
|
+
issues.push({ type: 'audio8-venv', severity: 'error', msg: `venv 缺 tokenizers。修复:${p.venvPy} -m pip install "tokenizers>=0.20,<0.23"` });
|
|
136
|
+
logger.error(`❌ venv 缺 tokenizers`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ---- 3. 模型核心文件 ----
|
|
141
|
+
const missingFiles = MODEL_CORE_FILES.filter(f => !fs.existsSync(path.join(p.model, f)));
|
|
142
|
+
if (missingFiles.length === MODEL_CORE_FILES.length) {
|
|
143
|
+
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`);
|
|
145
|
+
} else if (missingFiles.length > 0) {
|
|
146
|
+
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`);
|
|
148
|
+
} else {
|
|
149
|
+
let modelMB = null;
|
|
150
|
+
try { modelMB = Math.round(parseInt(sh(`du -sm "${p.model}" | cut -f1`), 10)); } catch (e) {}
|
|
151
|
+
logger.ok(`✓ 模型完整(${p.model}${modelMB ? `, ~${modelMB}MB` : ''})`);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ---- 4. 默认音色 ----
|
|
155
|
+
if (fs.existsSync(p.defaultVoiceMeta)) {
|
|
156
|
+
logger.ok(`✓ 默认音色 default`);
|
|
157
|
+
} else if (missingFiles.length === 0) {
|
|
158
|
+
// 模型在但音色缺(旧版本 fetch-model 不会自动 seed)
|
|
159
|
+
issues.push({ type: 'audio8-voice', severity: 'warn', msg: `默认音色缺失:${p.defaultVoiceMeta}。重跑 adoremix audio8-fetch-model(已有模型文件会秒过,仅补 seed)` });
|
|
160
|
+
logger.warn(`⚠ 默认音色 default 缺失,重跑 adoremix audio8-fetch-model 自动补`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ---- 5. 健康探测(服务 active 时才查)----
|
|
164
|
+
if (active === 'active') {
|
|
165
|
+
const code = sh(`curl -s -o /dev/null -w "%{http_code}" --max-time 5 "${HEALTH_URL}"`);
|
|
166
|
+
if (code === '200') {
|
|
167
|
+
logger.ok(`✓ /api/health 200`);
|
|
168
|
+
} else if (code === '000') {
|
|
169
|
+
logger.warn(`⚠ /api/health 无响应(模型冷启动中约 20-30 秒属正常,稍后重试)`);
|
|
170
|
+
} else {
|
|
171
|
+
issues.push({ type: 'audio8-health', severity: 'warn', msg: `/api/health 返回 HTTP ${code}` });
|
|
172
|
+
logger.warn(`⚠ /api/health HTTP ${code}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// ---- 6. 内存余量 ----
|
|
177
|
+
const memMB = memAvailableMB();
|
|
178
|
+
if (memMB !== null) {
|
|
179
|
+
if (memMB < 1000) {
|
|
180
|
+
issues.push({ type: 'audio8-mem', severity: 'error', msg: `可用内存 ${memMB}MB 不足(Audio8 模型常驻 ~1.8GB),加载会 OOM。建议换 ≥3GB 内存机器,或改用云端 TTS(xf/edge)` });
|
|
181
|
+
logger.error(`❌ 可用内存 ${memMB}MB < 1GB(模型加载需 ~1.8GB)`);
|
|
182
|
+
} else if (memMB < 2000) {
|
|
183
|
+
logger.warn(`⚠ 可用内存 ${memMB}MB 偏紧(模型常驻 ~1.8GB,建议 ≥3GB 总内存)`);
|
|
184
|
+
} else {
|
|
185
|
+
logger.ok(`✓ 可用内存 ${memMB}MB`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// ---- 7. 磁盘余量 ----
|
|
190
|
+
const diskMB = fs.existsSync(p.runtime) ? diskFreeMB(p.runtime) : null;
|
|
191
|
+
if (diskMB !== null && diskMB < 1024) {
|
|
192
|
+
issues.push({ type: 'audio8-disk', severity: 'warn', msg: `磁盘可用 ${diskMB}MB 不足 1GB(模型 423MB + venv ~500MB)` });
|
|
193
|
+
logger.warn(`⚠ 磁盘可用 ${diskMB}MB < 1GB`);
|
|
194
|
+
} else if (diskMB !== null) {
|
|
195
|
+
logger.ok(`✓ 磁盘可用 ${diskMB}MB`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
module.exports = { checkAudio8Deployment, isInstalled, RUNTIME_DIR };
|
package/src/doctor.js
CHANGED
|
@@ -439,6 +439,18 @@ function runDoctor(workdir, opts) {
|
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
441
|
|
|
442
|
+
// 9. Audio8 本机部署体检(Linux + 本机装了 audio8 或 provider=audio8 且指向本机时)
|
|
443
|
+
if (process.platform === 'linux') {
|
|
444
|
+
const a8 = require('./doctor-audio8');
|
|
445
|
+
const audio8BaseUrl = (cfgObj.TTS && cfgObj.TTS.audio8_base_url) || 'http://127.0.0.1:8024';
|
|
446
|
+
const isLocalProvider = providerName === 'audio8' && /^https?:\/\/(127\.0\.0\.1|localhost)(:|\/|$)/.test(audio8BaseUrl);
|
|
447
|
+
if (isLocalProvider || a8.isInstalled()) {
|
|
448
|
+
logger.log('');
|
|
449
|
+
logger.log('=== Audio8 本机部署检查 ===');
|
|
450
|
+
a8.checkAudio8Deployment(issues, { fix: !!opts.fix, providerActive: isLocalProvider });
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
442
454
|
return reportAndExit(issues, opts);
|
|
443
455
|
}
|
|
444
456
|
|
package/src/tts-deps.js
CHANGED
|
@@ -55,11 +55,11 @@ const PROVIDER_DEPENDENCIES = {
|
|
|
55
55
|
nodeModules: [], // 用 Node 内置 http/https
|
|
56
56
|
creds: [], // 本地服务无 API key
|
|
57
57
|
systemPkgs: [
|
|
58
|
-
{ name: 'ffmpeg', cmd: 'ffmpeg' } //
|
|
58
|
+
{ name: 'ffmpeg', cmd: 'ffmpeg' } // Audio8 服务端只返回 WAV,provider 层必须 ffmpeg 转 mp3
|
|
59
59
|
],
|
|
60
60
|
pipPkgs: [], // 纯 HTTP 调用,无 Python 依赖
|
|
61
61
|
executables: [...TRANSCODE_TOOLS],
|
|
62
|
-
//
|
|
62
|
+
// 额外:需要 Audio8 TTS 服务可达(checkDeps 末尾同步探测 /api/health)
|
|
63
63
|
extraChecks: ['http_endpoint']
|
|
64
64
|
}
|
|
65
65
|
};
|
|
@@ -241,37 +241,23 @@ function checkDeps(workdir, providerName, cfg) {
|
|
|
241
241
|
});
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
// audio8:探测本地服务可达性(GET /
|
|
244
|
+
// audio8:探测本地服务可达性(GET /api/health,超时 3 秒,同步等待结果)
|
|
245
245
|
if (providerName === 'audio8') {
|
|
246
|
-
const
|
|
247
|
-
const https = require('https');
|
|
248
|
-
const url = require('url');
|
|
249
|
-
const audio8BaseUrl = (cfg && cfg.TTS && cfg.TTS.audio8_base_url) || 'http://127.0.0.1:7860';
|
|
246
|
+
const audio8BaseUrl = (cfg && cfg.TTS && cfg.TTS.audio8_base_url) || 'http://127.0.0.1:8024';
|
|
250
247
|
let u;
|
|
251
248
|
try { u = new URL(audio8BaseUrl); } catch (e) {
|
|
252
|
-
issues.push({ severity: 'error', category: 'service', msg: `audio8_base_url 无效: ${audio8BaseUrl}(需 config.ini [TTS] audio8_base_url 配置,如 http://127.0.0.1:
|
|
249
|
+
issues.push({ severity: 'error', category: 'service', msg: `audio8_base_url 无效: ${audio8BaseUrl}(需 config.ini [TTS] audio8_base_url 配置,如 http://127.0.0.1:8024)`, autoFixable: false });
|
|
253
250
|
}
|
|
254
251
|
if (u) {
|
|
255
252
|
try {
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
timeout: 3000
|
|
263
|
-
}, res => {
|
|
264
|
-
if (res.statusCode !== 200) {
|
|
265
|
-
issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务不可达:${audio8BaseUrl} 返回 HTTP ${res.statusCode}`, autoFixable: false });
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
req.on('error', err => {
|
|
269
|
-
issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务不可达(${audio8BaseUrl}):${err.message}。请确认 Audio8 TTS 服务已启动(参考 Audio8-AI/Audio8_TTS),并在 config.ini [TTS] audio8_base_url 配置正确地址。`, autoFixable: false });
|
|
270
|
-
});
|
|
271
|
-
req.on('timeout', () => { req.destroy(); issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务超时(${audio8BaseUrl}/v1/models 3s 无响应)`, autoFixable: false }); });
|
|
272
|
-
req.end();
|
|
253
|
+
// http 回调是异步的,直接 push issue 会丢——用 execSync curl 同步探测
|
|
254
|
+
const out = execSync(`curl -s -o /dev/null -w "%{http_code}" --max-time 3 "${audio8BaseUrl.replace(/\/+$/, '')}/api/health"`,
|
|
255
|
+
{ shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
|
|
256
|
+
if (out !== '200') {
|
|
257
|
+
issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务异常:${audio8BaseUrl}/api/health 返回 HTTP ${out}。检查 systemctl status audio8-tts(本机部署时)或确认 audio8_base_url 指向的远程服务可达。`, autoFixable: false });
|
|
258
|
+
}
|
|
273
259
|
} catch (e) {
|
|
274
|
-
issues.push({ severity: 'error', category: 'service', msg: `
|
|
260
|
+
issues.push({ severity: 'error', category: 'service', msg: `Audio8 服务不可达(${audio8BaseUrl}):${String(e.message).split('\n')[0]}。本机部署用 systemctl restart audio8-tts 拉起;远程部署确认网络可达。`, autoFixable: false });
|
|
275
261
|
}
|
|
276
262
|
}
|
|
277
263
|
}
|
package/tts/providers/audio8.js
CHANGED
|
@@ -313,16 +313,11 @@ function install(opts) {
|
|
|
313
313
|
const cfg = require(path.join(__dirname, '..', '..', 'src', 'config'));
|
|
314
314
|
modelDir = cfg.getConfigValue(configWorkdir(), 'TTS.audio8_model_dir') || '';
|
|
315
315
|
} catch (e) {}
|
|
316
|
-
const modelLink = `~/audio8/${AUDIO8_RUNTIME_DIR}/model`; // Audio8 期望的模型目录
|
|
317
|
-
//
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
execSync(`mkdir -p $(dirname ${modelLink}) && rm -rf ${modelLink} && ln -s ${modelDir} ${modelLink}`, { stdio: 'inherit', shell: '/bin/bash' });
|
|
322
|
-
} catch (e) {
|
|
323
|
-
logger.warn('链接模型失败: ' + e.message);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
316
|
+
const modelLink = `~/audio8/${AUDIO8_RUNTIME_DIR}/model`; // Audio8 期望的模型目录(软链在源码就位后建)
|
|
317
|
+
// 重装保护:已有 model/voices(423MB+)先挪 /tmp 暂存,源码解压后还原——重跑 install 不用重新下模型
|
|
318
|
+
execSync(`rm -rf /tmp/audio8-keep && mkdir -p /tmp/audio8-keep; ` +
|
|
319
|
+
`for d in model voices; do if [ -e ~/audio8/${AUDIO8_RUNTIME_DIR}/$d ]; then mv ~/audio8/${AUDIO8_RUNTIME_DIR}/$d /tmp/audio8-keep/$d; fi; done; true`,
|
|
320
|
+
{ stdio: 'pipe', shell: '/bin/bash' });
|
|
326
321
|
|
|
327
322
|
// 拉 Audio8_TTS 源码:先试内置 tarball(主包 audio8-assets/audio8-tts.tgz,离线),再 git 镜像,最后 codeload
|
|
328
323
|
let cloned = false;
|
|
@@ -398,6 +393,19 @@ function install(opts) {
|
|
|
398
393
|
logger.log('当前内容: ' + execSync('ls ~/audio8', { shell: '/bin/bash', encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim().replace(/\n/g, ' '));
|
|
399
394
|
return 1;
|
|
400
395
|
}
|
|
396
|
+
// 还原暂存的 model/voices(重装保护的后半段;新装机没有暂存则跳过)
|
|
397
|
+
execSync(`for d in model voices; do if [ -e /tmp/audio8-keep/$d ]; then mkdir -p ~/audio8/${AUDIO8_RUNTIME_DIR}; mv /tmp/audio8-keep/$d ~/audio8/${AUDIO8_RUNTIME_DIR}/$d; fi; done; rm -rf /tmp/audio8-keep; true`,
|
|
398
|
+
{ stdio: 'pipe', shell: '/bin/bash' });
|
|
399
|
+
|
|
400
|
+
// config 配了预托管模型目录(audio8_model_dir)则软链覆盖(优先级高于还原的模型)
|
|
401
|
+
if (modelDir) {
|
|
402
|
+
try {
|
|
403
|
+
logger.log('=== 链接预托管模型 ' + modelDir + ' → ' + modelLink + ' ===');
|
|
404
|
+
execSync(`mkdir -p $(dirname ${modelLink}) && rm -rf ${modelLink} && ln -s ${modelDir} ${modelLink}`, { stdio: 'inherit', shell: '/bin/bash' });
|
|
405
|
+
} catch (e) {
|
|
406
|
+
logger.warn('链接模型失败: ' + e.message);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
401
409
|
|
|
402
410
|
// venv + pip install(Python 3.11+,numpy 2.4.3 需要)
|
|
403
411
|
// venv 路径必须与 AUDIO8_VENV_DIR/buildSystemdUnit 一致(~/audio8/onnx_runtime_0_1b_int8/.venv),
|