Spaces:
Running
Running
Encoder: prefer static INT8 (QLinearConv); INT4 fallback. Recovers 92.7%-class quality in browser
Browse files- mega-asr.js +12 -10
mega-asr.js
CHANGED
|
@@ -232,21 +232,23 @@ async function loadAll() {
|
|
| 232 |
setProgress(30);
|
| 233 |
|
| 234 |
// 3. ONNX sessions
|
| 235 |
-
//
|
| 236 |
-
//
|
| 237 |
-
//
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
let encUrl = `${HF_ROOT}/onnx/audio_encoder_int8.onnx`;
|
| 241 |
try {
|
| 242 |
-
state.encoder = await createSessionSimple(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
} catch (e) {
|
| 244 |
-
log(`INT8 encoder unsupported
|
| 245 |
-
encLabel = "audio_encoder INT4";
|
| 246 |
state.encoder = await createSession(
|
| 247 |
`${HF_ROOT}/onnx/audio_encoder_int4.onnx`,
|
| 248 |
`${HF_ROOT}/onnx/audio_encoder_int4.onnx.data`,
|
| 249 |
-
|
| 250 |
p => setProgress(30 + p * 10),
|
| 251 |
);
|
| 252 |
}
|
|
|
|
| 232 |
setProgress(30);
|
| 233 |
|
| 234 |
// 3. ONNX sessions
|
| 235 |
+
// Audio encoder: try static INT8 (QLinearConv/QLinearMatMul, browser-OK),
|
| 236 |
+
// then fall back to INT4 (MatMulNBits) if static INT8 also has issues.
|
| 237 |
+
// The OLD audio_encoder_int8.onnx uses ConvInteger (dynamic quant) which
|
| 238 |
+
// onnxruntime-web does NOT support — skipping that.
|
| 239 |
+
setLoaderStatus("audio encoder (INT8 static → INT4 fallback) ...");
|
|
|
|
| 240 |
try {
|
| 241 |
+
state.encoder = await createSessionSimple(
|
| 242 |
+
`${HF_ROOT}/onnx/audio_encoder_int8_static.onnx`,
|
| 243 |
+
"audio_encoder INT8 (static)",
|
| 244 |
+
p => setProgress(30 + p * 10),
|
| 245 |
+
);
|
| 246 |
} catch (e) {
|
| 247 |
+
log(`static INT8 encoder unsupported (${e.message}); falling back to INT4`);
|
|
|
|
| 248 |
state.encoder = await createSession(
|
| 249 |
`${HF_ROOT}/onnx/audio_encoder_int4.onnx`,
|
| 250 |
`${HF_ROOT}/onnx/audio_encoder_int4.onnx.data`,
|
| 251 |
+
"audio_encoder INT4",
|
| 252 |
p => setProgress(30 + p * 10),
|
| 253 |
);
|
| 254 |
}
|