@fugood/node-whisper-wasm 1.0.21 → 1.0.22
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/index.d.ts +2 -0
- package/index.js +23 -2
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -189,6 +189,7 @@ export declare function toggleNativeLog(
|
|
|
189
189
|
export declare function addNativeLogListener(
|
|
190
190
|
listener: (level: string, text: string) => void,
|
|
191
191
|
): { remove: () => void }
|
|
192
|
+
export declare function isNativeLogEnabled(): boolean
|
|
192
193
|
|
|
193
194
|
declare const _default: {
|
|
194
195
|
WhisperContext: typeof WhisperContext
|
|
@@ -200,6 +201,7 @@ declare const _default: {
|
|
|
200
201
|
initWhisperVad: typeof initWhisperVad
|
|
201
202
|
toggleNativeLog: typeof toggleNativeLog
|
|
202
203
|
addNativeLogListener: typeof addNativeLogListener
|
|
204
|
+
isNativeLogEnabled: typeof isNativeLogEnabled
|
|
203
205
|
isWasmThreadsSupported: typeof isWasmThreadsSupported
|
|
204
206
|
DEFAULT_WASM_MODEL_SIZE_LIMIT_BYTES: typeof DEFAULT_WASM_MODEL_SIZE_LIMIT_BYTES
|
|
205
207
|
MAX_WASM_THREADS: typeof MAX_WASM_THREADS
|
package/index.js
CHANGED
|
@@ -152,15 +152,32 @@ const createWhisperNodeApi = function (root) {
|
|
|
152
152
|
return options
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
function normalizeLogLevel(level) {
|
|
156
|
+
var normalized = String(level || '').toLowerCase()
|
|
157
|
+
if (normalized === 'warning') {
|
|
158
|
+
return 'warn'
|
|
159
|
+
}
|
|
160
|
+
if (
|
|
161
|
+
normalized === 'error' ||
|
|
162
|
+
normalized === 'warn' ||
|
|
163
|
+
normalized === 'info' ||
|
|
164
|
+
normalized === 'debug'
|
|
165
|
+
) {
|
|
166
|
+
return normalized
|
|
167
|
+
}
|
|
168
|
+
return normalized || 'info'
|
|
169
|
+
}
|
|
170
|
+
|
|
155
171
|
function emitLog(level, text) {
|
|
156
172
|
if (!logEnabled) {
|
|
157
173
|
return
|
|
158
174
|
}
|
|
175
|
+
var normalizedLevel = normalizeLogLevel(level)
|
|
159
176
|
if (typeof nativeLogCallback === 'function') {
|
|
160
|
-
nativeLogCallback(
|
|
177
|
+
nativeLogCallback(normalizedLevel, text)
|
|
161
178
|
}
|
|
162
179
|
logListeners.slice().forEach(function (listener) {
|
|
163
|
-
listener(
|
|
180
|
+
listener(normalizedLevel, text)
|
|
164
181
|
})
|
|
165
182
|
}
|
|
166
183
|
|
|
@@ -1473,6 +1490,9 @@ const createWhisperNodeApi = function (root) {
|
|
|
1473
1490
|
initWhisperVad: initWhisperVad,
|
|
1474
1491
|
toggleNativeLog: toggleNativeLog,
|
|
1475
1492
|
addNativeLogListener: addNativeLogListener,
|
|
1493
|
+
isNativeLogEnabled: function () {
|
|
1494
|
+
return logEnabled
|
|
1495
|
+
},
|
|
1476
1496
|
isWasmThreadsSupported: isWasmThreadsSupported,
|
|
1477
1497
|
DEFAULT_WASM_MODEL_SIZE_LIMIT_BYTES: 1500 * MIB,
|
|
1478
1498
|
MAX_WASM_THREADS: MAX_WASM_THREADS,
|
|
@@ -1498,6 +1518,7 @@ export const initWhisper = api.initWhisper
|
|
|
1498
1518
|
export const initWhisperVad = api.initWhisperVad
|
|
1499
1519
|
export const toggleNativeLog = api.toggleNativeLog
|
|
1500
1520
|
export const addNativeLogListener = api.addNativeLogListener
|
|
1521
|
+
export const isNativeLogEnabled = api.isNativeLogEnabled
|
|
1501
1522
|
export const isWasmThreadsSupported = api.isWasmThreadsSupported
|
|
1502
1523
|
|
|
1503
1524
|
if (root) {
|