@wu529778790/open-im 1.11.4-beta.4 → 1.11.4-beta.6
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 +5 -2
- package/dist/shared/tts.d.ts +1 -1
- package/dist/shared/tts.js +8 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -104,9 +104,12 @@ const PLATFORM_MODULES = {
|
|
|
104
104
|
const pc = config.platforms.clawbot;
|
|
105
105
|
if (pc?.apiUrl && pc?.apiToken) {
|
|
106
106
|
initClawBotSender(pc.apiUrl, pc.apiToken);
|
|
107
|
-
// 初始化 TTS
|
|
107
|
+
// 初始化 TTS — 从配置读取
|
|
108
108
|
const { initTTS } = await import('./shared/tts.js');
|
|
109
|
-
initTTS({
|
|
109
|
+
initTTS({
|
|
110
|
+
enabled: pc.tts?.enabled ?? false,
|
|
111
|
+
voice: pc.tts?.voice ?? 'zh',
|
|
112
|
+
});
|
|
110
113
|
}
|
|
111
114
|
const handle = setupClawbotHandlers(config, sessionManager);
|
|
112
115
|
await initClawbot(config, handle.handleEvent);
|
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
|
-
* 使用
|
|
3
|
+
* 使用 gTTS(Google Text-to-Speech)生成语音
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import gTTS from 'gtts';
|
|
6
6
|
import { createLogger } from '../logger.js';
|
|
7
7
|
import { mkdirSync, existsSync } from 'node:fs';
|
|
8
8
|
import { join } from 'node:path';
|
|
@@ -12,18 +12,16 @@ const log = createLogger('TTS');
|
|
|
12
12
|
/** 默认配置 */
|
|
13
13
|
const DEFAULT_TTS_CONFIG = {
|
|
14
14
|
enabled: false,
|
|
15
|
-
voice: 'zh
|
|
15
|
+
voice: 'zh',
|
|
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
|
-
|
|
26
|
-
log.info(`TTS enabled, voice: ${config.voice}`);
|
|
24
|
+
log.info(`TTS enabled, language: ${config.voice}`);
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
@@ -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,9 @@ 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
|
-
|
|
63
|
-
|
|
64
|
-
await tts.toFile(audioPath, cleanText);
|
|
59
|
+
// 调用 gTTS
|
|
60
|
+
const tts = new gTTS(cleanText, config.voice);
|
|
61
|
+
await tts.save(audioPath);
|
|
65
62
|
log.info(`TTS generated: ${audioPath}`);
|
|
66
63
|
return audioPath;
|
|
67
64
|
}
|
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.6",
|
|
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",
|