@oxiaom/adoremix 1.0.39 → 1.0.41

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.39",
3
+ "version": "1.0.41",
4
4
  "description": "AdoreMix broadcast server - cross-platform installer, runner and service manager",
5
5
  "bin": {
6
6
  "adoremix": "./bin/adoremix.js"
@@ -28,7 +28,7 @@ module.exports = {
28
28
  bitrate: 48,
29
29
  Pastcmd: 6008,
30
30
  BjPort: 6004,
31
- PackSize: 1024,
31
+ PackSize: 2048,
32
32
  RedisIP: '127.0.0.1',
33
33
  RedisPort: 6379,
34
34
  RedisAUTH: '',
@@ -103,6 +103,8 @@ module.exports = {
103
103
  xf_apiKey: '',
104
104
  xf_voice_override: '',
105
105
  minimax_token: '',
106
- edge_voice_override: ''
106
+ edge_voice_override: '',
107
+ audio8_base_url: 'http://127.0.0.1:7860',
108
+ audio8_voice_override: ''
107
109
  }
108
110
  };
package/src/tts-cli.js CHANGED
@@ -29,6 +29,12 @@ const PROVIDER_INFO = {
29
29
  desc: 'Microsoft Edge TTS(python)',
30
30
  cost: '免费',
31
31
  needsPython: true
32
+ },
33
+ audio8: {
34
+ name: 'Audio8 TTS',
35
+ desc: '本地 Audio8 TTS(OpenAI 兼容 API)',
36
+ cost: '免费(自部署)',
37
+ needsPython: false
32
38
  }
33
39
  };
34
40
 
package/src/tts-deps.js CHANGED
@@ -50,6 +50,17 @@ const PROVIDER_DEPENDENCIES = {
50
50
  ],
51
51
  pipPkgs: [{ pkg: 'edge-tts', import: 'edge_tts' }],
52
52
  executables: [{ name: 'ffmpeg', cmd: 'ffmpeg' }, ...TRANSCODE_TOOLS]
53
+ },
54
+ audio8: {
55
+ nodeModules: [], // 用 Node 内置 http/https
56
+ creds: [], // 本地服务无 API key
57
+ systemPkgs: [
58
+ { name: 'ffmpeg', cmd: 'ffmpeg' } // 转码用(实际 audio8 直接返回 mp3 不用 ffmpeg,但保留 fallback)
59
+ ],
60
+ pipPkgs: [], // 纯 HTTP 调用,无 Python 依赖
61
+ executables: [...TRANSCODE_TOOLS],
62
+ // 额外:需要本地 Audio8 TTS 服务可达(检查时探测 /v1/models)
63
+ extraChecks: ['http_endpoint']
53
64
  }
54
65
  };
55
66
 
@@ -230,6 +241,41 @@ function checkDeps(workdir, providerName, cfg) {
230
241
  });
231
242
  }
232
243
 
244
+ // audio8:探测本地服务可达性(GET /v1/models,超时 3 秒)
245
+ if (providerName === 'audio8') {
246
+ const http = require('http');
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';
250
+ let u;
251
+ 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:7860)`, autoFixable: false });
253
+ }
254
+ if (u) {
255
+ try {
256
+ const lib = u.protocol === 'https:' ? https : http;
257
+ const req = lib.request({
258
+ hostname: u.hostname,
259
+ port: u.port || (u.protocol === 'https:' ? 443 : 80),
260
+ path: '/v1/models',
261
+ method: 'GET',
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();
273
+ } catch (e) {
274
+ issues.push({ severity: 'error', category: 'service', msg: `audio8 服务探测失败:${e.message}`, autoFixable: false });
275
+ }
276
+ }
277
+ }
278
+
233
279
  return { issues, provider: providerName };
234
280
  }
235
281
 
@@ -0,0 +1,157 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Audio8 TTS provider
5
+ * 调用方式:HTTP 调用本地 Audio8 TTS 服务(OpenAI 兼容 /v1/audio/speech)
6
+ * 支持流式 MP3 输出(设备边收边播,匹配现有 quemp3 推送管道)
7
+ *
8
+ * 服务部署参考(Audio8-AI/Audio8_TTS):
9
+ * pip install audio8-tts(或依官方文档)
10
+ * python -m audio8_tts.server # 默认监听 http://0.0.0.0:7860
11
+ *
12
+ * 凭证:不需要 API Key(本地服务)
13
+ * 依赖:lame(mp3 转码),ffmpeg(HTTP 流 → mp3)
14
+ *
15
+ * 速度支持:x-speed 头(0.5~2.0,1.0=正常;2.0=2x 加速)
16
+ * 声音克隆:3~10 秒参考音频,但需在 Audio8 服务端预设(请求时用 voice 参数指定)
17
+ */
18
+
19
+ const { execFileSync } = require('child_process');
20
+ const fs = require('fs');
21
+ const path = require('path');
22
+ const os = require('os');
23
+ const https = require('https');
24
+ const http = require('http');
25
+ const { URL } = require('url');
26
+
27
+ // 中文常用 voice(Audio8 的 zh-CN voices,按性别分组)
28
+ const VOICES = {
29
+ // 女声
30
+ xiaoxiao: 'zh-CN-XiaoxiaoNeural', // 晓晓(温柔女声)
31
+ xiaoyi: 'zh-CN-XiaoyiNeural', // 晓伊(活力女声)
32
+ xiaomo: 'zh-CN-XiaomoNeural', // 晓墨(文艺女声)
33
+ xiaoxuan: 'zh-CN-XiaoxuanNeural', // 晓萱(新闻女声)
34
+ // 男声
35
+ yunxi: 'zh-CN-YunxiNeural', // 云希(青年男声)
36
+ yunjian: 'zh-CN-YunjianNeural', // 云健(浑厚男声)
37
+ yunyang: 'zh-CN-YunyangNeural', // 云扬(播音男声)
38
+ // 默认
39
+ default: 'zh-CN-XiaoxiaoNeural'
40
+ };
41
+
42
+ const DEFAULT_BASE_URL = 'http://127.0.0.1:7860';
43
+ const DEFAULT_TIMEOUT_MS = 30000;
44
+
45
+ function checkDeps() {
46
+ const issues = [];
47
+ // ffmpeg:HTTP 流 → mp3 文件
48
+ try {
49
+ execFileSync('ffmpeg', ['-version'], { stdio: 'pipe' });
50
+ } catch (e) {
51
+ issues.push({ msg: '未找到 ffmpeg(需要将 HTTP 流保存为 mp3 文件)', fix: 'apt-get install -y ffmpeg (Debian/Ubuntu) 或 yum install -y ffmpeg (CentOS/AlmaLinux)' });
52
+ }
53
+ return issues;
54
+ }
55
+
56
+ // 从 Audio8 服务拉 MP3 流,通过 ffmpeg 转为指定输出文件
57
+ // Audio8 服务返回 OpenAI 兼容的 audio/mpeg 流(直接是 mp3)
58
+ function streamToFile(audioStream, outFile) {
59
+ return new Promise((resolve, reject) => {
60
+ // 边收边写:tee 到临时文件,避免等全部下载
61
+ const tmpFile = outFile + '.part';
62
+ const ws = fs.createWriteStream(tmpFile);
63
+ let totalBytes = 0;
64
+ audioStream.on('data', chunk => {
65
+ totalBytes += chunk.length;
66
+ });
67
+ audioStream.on('error', err => {
68
+ ws.destroy();
69
+ try { fs.unlinkSync(tmpFile); } catch (e) {}
70
+ reject(new Error(`Audio8 流接收错误: ${err.message}`));
71
+ });
72
+ audioStream.pipe(ws);
73
+ ws.on('finish', () => {
74
+ try {
75
+ // Audio8 直接返回 audio/mpeg(mp3 流),无需 ffmpeg 转码
76
+ fs.renameSync(tmpFile, outFile);
77
+ resolve(totalBytes);
78
+ } catch (e) {
79
+ reject(new Error(`Audio8 临时文件改名失败: ${e.message}`));
80
+ }
81
+ });
82
+ ws.on('error', err => {
83
+ try { fs.unlinkSync(tmpFile); } catch (e) {}
84
+ reject(new Error(`Audio8 写文件失败: ${err.message}`));
85
+ });
86
+ });
87
+ }
88
+
89
+ function synthesize({ text, voice, volume, speed, outFile }, creds) {
90
+ return new Promise((resolve, reject) => {
91
+ const issues = checkDeps();
92
+ if (issues.length > 0) {
93
+ return reject(new Error('Audio8 依赖缺失:\n ' + issues.map(i => i.msg + ' (修复: ' + i.fix + ')').join('\n ')));
94
+ }
95
+
96
+ const baseUrl = (creds && creds.audio8_base_url) || DEFAULT_BASE_URL;
97
+ const wantedVoice = VOICES[voice] || VOICES.default;
98
+ // 音量:Audio8 用 dB 偏移(-6~6 dB),UI 传的是 0~100 百分比,转 dB
99
+ const vo = parseInt(volume) || 50;
100
+ const volumeDb = Math.round((vo - 50) * 0.12);
101
+ // 速度:Audio8 用 0.5~2.0 倍速,UI 传 0~100 转 0.5~2.0
102
+ const sp = parseInt(speed) || 50;
103
+ const speedMul = 0.5 + (sp / 100) * 1.5;
104
+
105
+ // OpenAI 兼容调用:POST /v1/audio/speech,body=json,response=audio/mpeg 流
106
+ let urlObj;
107
+ try { urlObj = new URL(baseUrl); } catch (e) {
108
+ return reject(new Error(`Audio8 服务地址无效: ${baseUrl}(请在 config.ini [TTS] audio8_base_url 配置,例 http://127.0.0.1:7860)`));
109
+ }
110
+ urlObj.pathname = '/v1/audio/speech';
111
+ const postData = JSON.stringify({
112
+ input: text,
113
+ voice: wantedVoice,
114
+ model: 'audio8-tts',
115
+ response_format: 'mp3',
116
+ speed: speedMul,
117
+ volume: volumeDb
118
+ });
119
+ const opts = {
120
+ hostname: urlObj.hostname,
121
+ port: urlObj.port || (urlObj.protocol === 'https:' ? 443 : 80),
122
+ path: urlObj.pathname,
123
+ method: 'POST',
124
+ headers: {
125
+ 'Content-Type': 'application/json',
126
+ 'Content-Length': Buffer.byteLength(postData)
127
+ },
128
+ timeout: DEFAULT_TIMEOUT_MS
129
+ };
130
+ const lib = urlObj.protocol === 'https:' ? https : http;
131
+ const req = lib.request(opts, res => {
132
+ if (res.statusCode !== 200) {
133
+ let body = '';
134
+ res.on('data', c => body += c);
135
+ res.on('end', () => {
136
+ reject(new Error(`Audio8 返回 HTTP ${res.statusCode}: ${body.slice(0, 200)}`));
137
+ });
138
+ return;
139
+ }
140
+ // 流式保存
141
+ streamToFile(res, outFile)
142
+ .then(bytes => resolve({ bytes }))
143
+ .catch(reject);
144
+ });
145
+ req.on('error', err => {
146
+ reject(new Error(`Audio8 连接失败(${baseUrl}): ${err.message}。请确认 Audio8 TTS 服务已启动,且 config.ini [TTS] audio8_base_url 配置正确。`));
147
+ });
148
+ req.on('timeout', () => {
149
+ req.destroy();
150
+ reject(new Error(`Audio8 请求超时(${DEFAULT_TIMEOUT_MS / 1000}s)。服务可能在转码长文本。`));
151
+ });
152
+ req.write(postData);
153
+ req.end();
154
+ });
155
+ }
156
+
157
+ module.exports = { synthesize, checkDeps, VOICES, DEFAULT_BASE_URL };
package/tts/tts.js CHANGED
@@ -11,6 +11,7 @@
11
11
  * - xf: 讯飞 WebSocket(原 tts.js 逻辑,需 appid/apiSecret/apiKey)
12
12
  * - minimax: MiniMax HTTP API(需 token)
13
13
  * - edge: python edge-tts(免费,需 python3 + ffmpeg)
14
+ * - audio8: 本地 Audio8 TTS(OpenAI 兼容 API,需 audio8_base_url 配置 + ffmpeg)
14
15
  *
15
16
  * 凭证优先从 config.ini 读,命令行 appid/apiSecret/apiKey 兼容旧调用(仅 xf)。
16
17
  */
@@ -22,7 +23,8 @@ const ini = require('ini');
22
23
  const PROVIDERS = {
23
24
  xf: require('./providers/xf'),
24
25
  minimax: require('./providers/minimax'),
25
- edge: require('./providers/edge')
26
+ edge: require('./providers/edge'),
27
+ audio8: require('./providers/audio8')
26
28
  };
27
29
 
28
30
  function log(...args) { console.log('[tts]', ...args); }