@wu529778790/open-im 1.11.4-beta.5 → 1.11.4-beta.7
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/dist/index.js +1 -1
- package/dist/shared/tts.d.ts +1 -1
- package/dist/shared/tts.js +15 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ const PLATFORM_MODULES = {
|
|
|
108
108
|
const { initTTS } = await import('./shared/tts.js');
|
|
109
109
|
initTTS({
|
|
110
110
|
enabled: pc.tts?.enabled ?? false,
|
|
111
|
-
voice: pc.tts?.voice ?? 'zh
|
|
111
|
+
voice: pc.tts?.voice ?? 'zh',
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
const handle = setupClawbotHandlers(config, sessionManager);
|
package/dist/shared/tts.d.ts
CHANGED
package/dist/shared/tts.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TTS (Text-to-Speech) 模块
|
|
3
|
-
* 使用 edge-tts
|
|
3
|
+
* 使用 Python edge-tts 生成语音(微软 Edge TTS)
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { execFile } from 'node:child_process';
|
|
6
6
|
import { createLogger } from '../logger.js';
|
|
7
7
|
import { mkdirSync, existsSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
@@ -15,14 +15,12 @@ const DEFAULT_TTS_CONFIG = {
|
|
|
15
15
|
voice: 'zh-CN-XiaoxiaoNeural',
|
|
16
16
|
};
|
|
17
17
|
let config = DEFAULT_TTS_CONFIG;
|
|
18
|
-
let tts = null;
|
|
19
18
|
/**
|
|
20
19
|
* 初始化 TTS
|
|
21
20
|
*/
|
|
22
21
|
export function initTTS(cfg) {
|
|
23
22
|
config = { ...DEFAULT_TTS_CONFIG, ...cfg };
|
|
24
23
|
if (config.enabled) {
|
|
25
|
-
tts = new MsEdgeTTS({ enableLogger: false });
|
|
26
24
|
log.info(`TTS enabled, voice: ${config.voice}`);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
@@ -37,7 +35,7 @@ export function getTTSConfig() {
|
|
|
37
35
|
* @returns 音频文件路径
|
|
38
36
|
*/
|
|
39
37
|
export async function textToSpeech(text) {
|
|
40
|
-
if (!config.enabled
|
|
38
|
+
if (!config.enabled) {
|
|
41
39
|
return null;
|
|
42
40
|
}
|
|
43
41
|
try {
|
|
@@ -58,10 +56,18 @@ export async function textToSpeech(text) {
|
|
|
58
56
|
mkdirSync(audioDir, { recursive: true });
|
|
59
57
|
}
|
|
60
58
|
const audioPath = join(audioDir, `tts-${randomBytes(8).toString('hex')}.mp3`);
|
|
61
|
-
//
|
|
62
|
-
await
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
// 调用 Python edge-tts
|
|
60
|
+
await new Promise((resolve, reject) => {
|
|
61
|
+
execFile('python3', ['-m', 'edge_tts', '--voice', config.voice, '--text', cleanText, '--write-media', audioPath], { timeout: 30000 }, (error, stdout, stderr) => {
|
|
62
|
+
if (error) {
|
|
63
|
+
log.error('TTS exec failed:', error.message);
|
|
64
|
+
reject(error);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
resolve();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
65
71
|
log.info(`TTS generated: ${audioPath}`);
|
|
66
72
|
return audioPath;
|
|
67
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wu529778790/open-im",
|
|
3
|
-
"version": "1.11.4-beta.
|
|
3
|
+
"version": "1.11.4-beta.7",
|
|
4
4
|
"description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|