@wu529778790/open-im 1.11.4-beta.6 → 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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * TTS (Text-to-Speech) 模块
3
- * 使用 gTTS(Google Text-to-Speech)生成语音
3
+ * 使用 Python edge-tts 生成语音(微软 Edge TTS)
4
4
  */
5
5
  /** TTS 配置 */
6
6
  export interface TTSConfig {
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * TTS (Text-to-Speech) 模块
3
- * 使用 gTTS(Google Text-to-Speech)生成语音
3
+ * 使用 Python edge-tts 生成语音(微软 Edge TTS)
4
4
  */
5
- import gTTS from 'gtts';
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';
@@ -12,7 +12,7 @@ const log = createLogger('TTS');
12
12
  /** 默认配置 */
13
13
  const DEFAULT_TTS_CONFIG = {
14
14
  enabled: false,
15
- voice: 'zh',
15
+ voice: 'zh-CN-XiaoxiaoNeural',
16
16
  };
17
17
  let config = DEFAULT_TTS_CONFIG;
18
18
  /**
@@ -21,7 +21,7 @@ let config = DEFAULT_TTS_CONFIG;
21
21
  export function initTTS(cfg) {
22
22
  config = { ...DEFAULT_TTS_CONFIG, ...cfg };
23
23
  if (config.enabled) {
24
- log.info(`TTS enabled, language: ${config.voice}`);
24
+ log.info(`TTS enabled, voice: ${config.voice}`);
25
25
  }
26
26
  }
27
27
  /**
@@ -56,9 +56,18 @@ export async function textToSpeech(text) {
56
56
  mkdirSync(audioDir, { recursive: true });
57
57
  }
58
58
  const audioPath = join(audioDir, `tts-${randomBytes(8).toString('hex')}.mp3`);
59
- // 调用 gTTS
60
- const tts = new gTTS(cleanText, config.voice);
61
- await tts.save(audioPath);
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
+ });
62
71
  log.info(`TTS generated: ${audioPath}`);
63
72
  return audioPath;
64
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.4-beta.6",
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",