agentgui 1.0.182 → 1.0.183
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 +6 -0
- package/package.json +1 -1
package/lib/speech.js
CHANGED
|
@@ -120,12 +120,16 @@ async function loadTransformers() {
|
|
|
120
120
|
return transformersModule;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
const PERSISTENT_CACHE = path.join(os.homedir(), '.gmgui', 'models');
|
|
124
|
+
|
|
123
125
|
function whisperModelPath() {
|
|
124
126
|
try {
|
|
125
127
|
const webtalkDir = path.dirname(require.resolve('webtalk'));
|
|
126
128
|
const p = path.join(webtalkDir, 'models', 'onnx-community', 'whisper-base');
|
|
127
129
|
if (fs.existsSync(p)) return p;
|
|
128
130
|
} catch (_) {}
|
|
131
|
+
const cached = path.join(PERSISTENT_CACHE, 'onnx-community', 'whisper-base');
|
|
132
|
+
if (fs.existsSync(cached)) return cached;
|
|
129
133
|
return 'onnx-community/whisper-base';
|
|
130
134
|
}
|
|
131
135
|
|
|
@@ -175,9 +179,11 @@ async function getSTT() {
|
|
|
175
179
|
const isLocal = !modelPath.includes('/') || fs.existsSync(modelPath);
|
|
176
180
|
env.allowLocalModels = true;
|
|
177
181
|
env.allowRemoteModels = !isLocal;
|
|
182
|
+
env.cacheDir = PERSISTENT_CACHE;
|
|
178
183
|
if (isLocal) env.localModelPath = '';
|
|
179
184
|
sttPipeline = await pipeline('automatic-speech-recognition', modelPath, {
|
|
180
185
|
device: 'cpu',
|
|
186
|
+
cache_dir: PERSISTENT_CACHE,
|
|
181
187
|
local_files_only: isLocal,
|
|
182
188
|
});
|
|
183
189
|
sttLoadError = null;
|