agentgui 1.0.277 → 1.0.279
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/lib/speech.js +11 -2
- package/package.json +1 -1
- package/server.js +70 -95
package/lib/speech.js
CHANGED
|
@@ -134,11 +134,20 @@ function preloadTTS() {
|
|
|
134
134
|
console.log('[TTS] pocket-tts functions not available');
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
+
if (typeof serverTTS.isInstalled === 'function' && !serverTTS.isInstalled()) {
|
|
138
|
+
console.log('[TTS] pocket-tts not installed yet - will install on first use');
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const portableDataDir = process.env.PORTABLE_DATA_DIR;
|
|
142
|
+
const binaryPaths = portableDataDir ? [
|
|
143
|
+
path.join(portableDataDir, 'pocket-venv', 'Scripts', 'pocket-tts.exe'),
|
|
144
|
+
path.join(portableDataDir, 'pocket-venv', 'bin', 'pocket-tts'),
|
|
145
|
+
] : undefined;
|
|
137
146
|
const defaultVoice = serverTTS.findVoiceFile('custom_cleetus', EXTRA_VOICE_DIRS) || '/config/voices/cleetus.wav';
|
|
138
147
|
const voicePath = fs.existsSync(defaultVoice) ? defaultVoice : null;
|
|
139
|
-
serverTTS.start(voicePath, {}).then(ok => {
|
|
148
|
+
serverTTS.start(voicePath, binaryPaths ? { binaryPaths } : {}).then(ok => {
|
|
140
149
|
if (ok) console.log('[TTS] pocket-tts sidecar started');
|
|
141
|
-
else console.log('[TTS] pocket-tts
|
|
150
|
+
else console.log('[TTS] pocket-tts not available - will use edge-tts fallback');
|
|
142
151
|
}).catch(err => {
|
|
143
152
|
console.error('[TTS] pocket-tts start error:', err.message);
|
|
144
153
|
});
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -91,116 +91,91 @@ async function ensureModelsDownloaded() {
|
|
|
91
91
|
const totalFiles = 16;
|
|
92
92
|
let completedFiles = 0;
|
|
93
93
|
|
|
94
|
+
const require = createRequire(import.meta.url);
|
|
95
|
+
|
|
94
96
|
if (!sttOk) {
|
|
95
|
-
console.log('[MODELS] Downloading STT model via IPFS...');
|
|
96
97
|
broadcastModelProgress({ started: true, done: false, downloading: true, type: 'stt', source: 'ipfs', completedFiles, totalFiles });
|
|
97
|
-
|
|
98
|
+
let sttDownloaded = false;
|
|
99
|
+
|
|
100
|
+
const LIGHTHOUSE_STT_CID = 'bafybeidyw252ecy4vs46bbmezrtw325gl2ymdltosmzqgx4edjsc3fbofy';
|
|
101
|
+
const lighthouseSttBase = `https://gateway.lighthouse.storage/ipfs/${LIGHTHOUSE_STT_CID}/stt/onnx-community/whisper-base/`;
|
|
102
|
+
const whisperModels = require('webtalk/whisper-models');
|
|
103
|
+
console.log('[MODELS] Downloading STT from Lighthouse IPFS:', LIGHTHOUSE_STT_CID);
|
|
104
|
+
fs.mkdirSync(sttDir, { recursive: true });
|
|
105
|
+
const WHISPER_FILES = [
|
|
106
|
+
'config.json', 'preprocessor_config.json', 'tokenizer.json',
|
|
107
|
+
'tokenizer_config.json', 'vocab.json', 'merges.txt',
|
|
108
|
+
'model_quantized.onnx', 'onnx/encoder_model.onnx',
|
|
109
|
+
'onnx/decoder_model_merged_q4.onnx', 'onnx/decoder_model_merged.onnx'
|
|
110
|
+
];
|
|
98
111
|
try {
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
error: 'STT model CID not registered - speech will be unavailable. Register via IPFS.',
|
|
106
|
-
type: 'stt',
|
|
107
|
-
completedFiles,
|
|
108
|
-
totalFiles
|
|
109
|
-
});
|
|
110
|
-
} else {
|
|
111
|
-
console.log('[MODELS] Downloading STT from Lighthouse IPFS:', ipfsCid.cid);
|
|
112
|
-
fs.mkdirSync(sttDir, { recursive: true });
|
|
113
|
-
|
|
114
|
-
// Download from Lighthouse gateway: https://gateway.lighthouse.storage/ipfs/CID/stt/onnx-community/whisper-base/
|
|
115
|
-
const lighthouseGateway = 'https://gateway.lighthouse.storage/ipfs';
|
|
116
|
-
const sttUrl = `${lighthouseGateway}/${ipfsCid.cid}/stt/onnx-community/whisper-base/onnx/`;
|
|
117
|
-
const sttFile = path.join(sttDir, 'whisper-onnx.tar');
|
|
118
|
-
|
|
119
|
-
await IPFSDownloader.downloadWithProgress(
|
|
120
|
-
sttUrl,
|
|
121
|
-
sttFile,
|
|
122
|
-
(progress) => {
|
|
123
|
-
broadcastModelProgress({
|
|
124
|
-
started: true,
|
|
125
|
-
done: false,
|
|
126
|
-
downloading: true,
|
|
127
|
-
type: 'stt',
|
|
128
|
-
source: 'lighthouse-ipfs',
|
|
129
|
-
gateway: 'gateway.lighthouse.storage',
|
|
130
|
-
...progress,
|
|
131
|
-
completedFiles,
|
|
132
|
-
totalFiles
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
console.log('[MODELS] STT model downloaded successfully from Lighthouse IPFS');
|
|
112
|
+
for (const file of WHISPER_FILES) {
|
|
113
|
+
const dest = path.join(sttDir, file);
|
|
114
|
+
if (!fs.existsSync(dest)) {
|
|
115
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
116
|
+
await whisperModels.downloadFile(lighthouseSttBase + file, dest, 3);
|
|
117
|
+
}
|
|
137
118
|
}
|
|
119
|
+
console.log('[MODELS] STT model downloaded from Lighthouse IPFS');
|
|
120
|
+
sttDownloaded = true;
|
|
138
121
|
} catch (err) {
|
|
139
|
-
console.error('[MODELS] IPFS STT download failed:', err.message);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
122
|
+
console.error('[MODELS] IPFS STT download failed:', err.message, '- falling back to HuggingFace');
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (!sttDownloaded) {
|
|
126
|
+
console.log('[MODELS] Downloading STT model via HuggingFace...');
|
|
127
|
+
broadcastModelProgress({ started: true, done: false, downloading: true, type: 'stt', source: 'huggingface', completedFiles, totalFiles });
|
|
128
|
+
try {
|
|
129
|
+
const modelsDir = path.join(dataDir, 'models');
|
|
130
|
+
fs.mkdirSync(modelsDir, { recursive: true });
|
|
131
|
+
await whisperModels.ensureModel('onnx-community/whisper-base', {
|
|
132
|
+
modelsDir,
|
|
133
|
+
whisperBaseUrl: 'https://huggingface.co/',
|
|
134
|
+
});
|
|
135
|
+
console.log('[MODELS] STT model downloaded from HuggingFace');
|
|
136
|
+
} catch (hfErr) {
|
|
137
|
+
console.error('[MODELS] HuggingFace STT download failed:', hfErr.message);
|
|
138
|
+
broadcastModelProgress({ done: true, error: `STT download failed: ${hfErr.message}`, type: 'stt', completedFiles, totalFiles });
|
|
139
|
+
}
|
|
147
140
|
}
|
|
148
141
|
completedFiles += 10;
|
|
149
142
|
}
|
|
150
143
|
|
|
151
144
|
if (!ttsOk) {
|
|
152
|
-
console.log('[MODELS] Downloading TTS models via IPFS...');
|
|
153
145
|
broadcastModelProgress({ started: true, done: false, downloading: true, type: 'tts', source: 'ipfs', completedFiles, totalFiles });
|
|
146
|
+
let ttsDownloaded = false;
|
|
154
147
|
|
|
148
|
+
const LIGHTHOUSE_TTS_CID = 'bafybeidyw252ecy4vs46bbmezrtw325gl2ymdltosmzqgx4edjsc3fbofy';
|
|
149
|
+
const lighthouseTtsBase = `https://gateway.lighthouse.storage/ipfs/${LIGHTHOUSE_TTS_CID}/tts/`;
|
|
150
|
+
const ttsModels = require('webtalk/tts-models');
|
|
151
|
+
console.log('[MODELS] Downloading TTS from Lighthouse IPFS:', LIGHTHOUSE_TTS_CID);
|
|
152
|
+
fs.mkdirSync(ttsDir, { recursive: true });
|
|
155
153
|
try {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
154
|
+
await ttsModels.ensureTTSModels({
|
|
155
|
+
ttsModelsDir: ttsDir,
|
|
156
|
+
ttsDir: path.join(dataDir, 'models', 'tts'),
|
|
157
|
+
ttsBaseUrl: lighthouseTtsBase,
|
|
158
|
+
});
|
|
159
|
+
console.log('[MODELS] TTS models downloaded from Lighthouse IPFS');
|
|
160
|
+
ttsDownloaded = true;
|
|
161
|
+
} catch (err) {
|
|
162
|
+
console.error('[MODELS] IPFS TTS download failed:', err.message, '- falling back to HuggingFace');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!ttsDownloaded) {
|
|
166
|
+
console.log('[MODELS] Downloading TTS models via HuggingFace...');
|
|
167
|
+
broadcastModelProgress({ started: true, done: false, downloading: true, type: 'tts', source: 'huggingface', completedFiles, totalFiles });
|
|
168
|
+
try {
|
|
169
|
+
await ttsModels.ensureTTSModels({
|
|
170
|
+
ttsModelsDir: ttsDir,
|
|
171
|
+
ttsDir: path.join(dataDir, 'models', 'tts'),
|
|
172
|
+
ttsBaseUrl: 'https://huggingface.co/datasets/AnEntrypoint/sttttsmodels/resolve/main/tts/',
|
|
166
173
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// Download from Lighthouse gateway: https://gateway.lighthouse.storage/ipfs/CID/tts/
|
|
172
|
-
const lighthouseGateway = 'https://gateway.lighthouse.storage/ipfs';
|
|
173
|
-
const ttsUrl = `${lighthouseGateway}/${ipfsCid.cid}/tts/`;
|
|
174
|
-
const ttsFile = path.join(ttsDir, 'tts-models.tar');
|
|
175
|
-
|
|
176
|
-
await IPFSDownloader.downloadWithProgress(
|
|
177
|
-
ttsUrl,
|
|
178
|
-
ttsFile,
|
|
179
|
-
(progress) => {
|
|
180
|
-
broadcastModelProgress({
|
|
181
|
-
started: true,
|
|
182
|
-
done: false,
|
|
183
|
-
downloading: true,
|
|
184
|
-
type: 'tts',
|
|
185
|
-
source: 'lighthouse-ipfs',
|
|
186
|
-
gateway: 'gateway.lighthouse.storage',
|
|
187
|
-
...progress,
|
|
188
|
-
completedFiles,
|
|
189
|
-
totalFiles
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
);
|
|
193
|
-
console.log('[MODELS] TTS models downloaded successfully from Lighthouse IPFS');
|
|
174
|
+
console.log('[MODELS] TTS models downloaded from HuggingFace');
|
|
175
|
+
} catch (hfErr) {
|
|
176
|
+
console.error('[MODELS] HuggingFace TTS download failed:', hfErr.message);
|
|
177
|
+
broadcastModelProgress({ done: true, error: `TTS download failed: ${hfErr.message}`, type: 'tts', completedFiles, totalFiles });
|
|
194
178
|
}
|
|
195
|
-
} catch (err) {
|
|
196
|
-
console.error('[MODELS] IPFS TTS download failed:', err.message);
|
|
197
|
-
broadcastModelProgress({
|
|
198
|
-
done: true,
|
|
199
|
-
error: `IPFS TTS download failed: ${err.message}`,
|
|
200
|
-
type: 'tts',
|
|
201
|
-
completedFiles,
|
|
202
|
-
totalFiles
|
|
203
|
-
});
|
|
204
179
|
}
|
|
205
180
|
completedFiles += 6;
|
|
206
181
|
}
|