agentgui 1.0.223 → 1.0.225
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/bin/gmgui.cjs +6 -12
- package/lib/speech.js +5 -39
- package/package.json +1 -1
package/bin/gmgui.cjs
CHANGED
|
@@ -5,21 +5,15 @@ const fs = require('fs');
|
|
|
5
5
|
|
|
6
6
|
const projectRoot = path.join(__dirname, '..');
|
|
7
7
|
|
|
8
|
-
function hasBun() {
|
|
9
|
-
try {
|
|
10
|
-
spawnSync('which', ['bun'], { stdio: 'pipe' });
|
|
11
|
-
return true;
|
|
12
|
-
} catch {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
8
|
async function gmgui(args = []) {
|
|
18
9
|
const command = args[0] || 'start';
|
|
19
10
|
|
|
20
11
|
if (command === 'start') {
|
|
21
|
-
|
|
22
|
-
|
|
12
|
+
// Always use node as runtime for reliability. When invoked via bunx,
|
|
13
|
+
// dependencies are already managed. When invoked via npm/npx, we install
|
|
14
|
+
// dependencies ourselves. This avoids ENOENT errors on systems where bun
|
|
15
|
+
// may not be in PATH even though bunx works.
|
|
16
|
+
const installer = 'npm';
|
|
23
17
|
|
|
24
18
|
// Ensure dependencies are installed only if node_modules is missing
|
|
25
19
|
// Skip this for bunx which manages dependencies independently
|
|
@@ -39,7 +33,7 @@ async function gmgui(args = []) {
|
|
|
39
33
|
|
|
40
34
|
const port = process.env.PORT || 3000;
|
|
41
35
|
const baseUrl = process.env.BASE_URL || '/gm';
|
|
42
|
-
const runtime =
|
|
36
|
+
const runtime = 'node';
|
|
43
37
|
|
|
44
38
|
return new Promise((resolve, reject) => {
|
|
45
39
|
const ps = spawn(runtime, [path.join(projectRoot, 'server.js')], {
|
package/lib/speech.js
CHANGED
|
@@ -27,12 +27,6 @@ const POCKET_TTS_VOICES = [
|
|
|
27
27
|
];
|
|
28
28
|
|
|
29
29
|
const PREDEFINED_IDS = new Set(POCKET_TTS_VOICES.filter(v => v.id !== 'default').map(v => v.id));
|
|
30
|
-
const FALLBACK_VOICE = 'cosette';
|
|
31
|
-
|
|
32
|
-
function isVoiceCloningError(err) {
|
|
33
|
-
const msg = (err.message || err.stderr || String(err)).toLowerCase();
|
|
34
|
-
return msg.includes('voice cloning') || msg.includes('could not download the weights');
|
|
35
|
-
}
|
|
36
30
|
const POCKET_PORT = 8787;
|
|
37
31
|
|
|
38
32
|
const needsPatch = !serverTTS.getVoices(EXTRA_VOICE_DIRS).some(v => v.id === 'alba' && !v.isCustom);
|
|
@@ -85,19 +79,11 @@ function getSTT() {
|
|
|
85
79
|
return serverSTT.getSTT();
|
|
86
80
|
}
|
|
87
81
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return await synthesizeDirect(text, voiceId);
|
|
92
|
-
}
|
|
93
|
-
return await serverTTS.synthesize(text, voiceId, EXTRA_VOICE_DIRS);
|
|
94
|
-
} catch (err) {
|
|
95
|
-
if (isVoiceCloningError(err) && voiceId && !PREDEFINED_IDS.has(voiceId)) {
|
|
96
|
-
console.log(`[TTS] Voice cloning failed for "${voiceId}", falling back to ${FALLBACK_VOICE}`);
|
|
97
|
-
return synthesize(text, FALLBACK_VOICE);
|
|
98
|
-
}
|
|
99
|
-
throw err;
|
|
82
|
+
function synthesize(text, voiceId) {
|
|
83
|
+
if (needsPatch && voiceId && PREDEFINED_IDS.has(voiceId)) {
|
|
84
|
+
return synthesizeDirect(text, voiceId);
|
|
100
85
|
}
|
|
86
|
+
return serverTTS.synthesize(text, voiceId, EXTRA_VOICE_DIRS);
|
|
101
87
|
}
|
|
102
88
|
|
|
103
89
|
function synthesizeStream(text, voiceId) {
|
|
@@ -109,27 +95,7 @@ function synthesizeStream(text, voiceId) {
|
|
|
109
95
|
}
|
|
110
96
|
})();
|
|
111
97
|
}
|
|
112
|
-
return
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function synthesizeStreamWithFallback(text, voiceId) {
|
|
116
|
-
let fellBack = false;
|
|
117
|
-
const upstream = serverTTS.synthesizeStream(text, voiceId, EXTRA_VOICE_DIRS);
|
|
118
|
-
return (async function* () {
|
|
119
|
-
try {
|
|
120
|
-
for await (const chunk of upstream) {
|
|
121
|
-
yield chunk;
|
|
122
|
-
}
|
|
123
|
-
} catch (err) {
|
|
124
|
-
if (!fellBack && isVoiceCloningError(err) && voiceId && !PREDEFINED_IDS.has(voiceId)) {
|
|
125
|
-
fellBack = true;
|
|
126
|
-
console.log(`[TTS] Voice cloning failed for "${voiceId}", falling back to ${FALLBACK_VOICE}`);
|
|
127
|
-
yield* synthesizeStream(text, FALLBACK_VOICE);
|
|
128
|
-
} else {
|
|
129
|
-
throw err;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
})();
|
|
98
|
+
return serverTTS.synthesizeStream(text, voiceId, EXTRA_VOICE_DIRS);
|
|
133
99
|
}
|
|
134
100
|
|
|
135
101
|
function getVoices() {
|