iflytek/astron-agent · error
未加载 编码器
Error message
未加载${set.type}编码器 What it means
Recorder-Core's stop() verifies that the encoder for set.type (e.g. 'wav', 'mp3') is registered on the recorder instance; This[set.type] is falsy when the corresponding encoder plugin/extension was never loaded, so stop cannot transcode the PCM buffers.
Solutions
- Include the encoder script for the configured type (e.g. <script src="recorder-mp3.min.js">) after recorder-core.js.
- Ensure set.type exactly matches the registered encoder name (case-sensitive).
- Verify with your bundler that the encoder module's side-effect (window.Recorder['mp3']=...) isn't stripped; import it for side effects.
- Log Object.keys available encoders and check set.type before calling stop.
- Fall back to a format you know is loaded (e.g. wav) if the desired encoder is unavailable.
Example fix
// before
Recorder({ type: 'mp3', ... }) // recorder-mp3.js never loaded
// after
<script src="recorder-core.js"></script>
<script src="recorder-mp3.min.js"></script>
...
if (!Recorder['mp3'] /* or window-level check */) {
showToast('MP3 encoder not loaded');
} else {
rec.stop(uploadBlob);
} Defensive patterns
Strategy: validation
Validate before calling
const types = ['wav', 'mp3'];
if (!Recorder[set.type] && !window.Recorder?.[set.type]) {
throw new Error(`Encoder for type '${set.type}' not loaded — include its script`);
} Type guard
function encoderLoaded(type) { return typeof window.Recorder === 'object' && !!Recorder[type]; } Try / catch
if (!encoderLoaded(rec.set.type)) {
showToast('Encoder missing: ' + rec.set.type);
return;
}
rec.stop(uploadBlob); Prevention
- Ship the encoder script matching every configured set.type.
- Match set.type exactly (case) to the registered encoder key.
- Import encoder modules for side effects in bundled apps.
- Add a startup check that all needed encoders are registered.
When it happens
Trigger: stop() called with set.type set to a format whose encoder file (e.g. recorder-mp3.js defining Recorder.MP3 encoder context) was never included, or set.type string doesn't match the registered encoder key.
Common situations: Set type:'mp3' but only recorder-core.js loaded without recorder-mp3.min.js; typo in set.type ('MP3' vs 'mp3' case mismatch); bundler tree-shook the encoder side-effect registration; dynamically chosen type not reflected in the scripts loaded on the page.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/4b3b950e80ad882b.
Report an issue: GitHub.
Appendix: source
Thrown at console/frontend/src/utils/record/recorder-core.js:1391
err(
'未开始录音' +
(isCtxWait ? ',开始录音前无用户交互导致AudioContext未运行' : '')
);
return;
}
This._stop(true);
}
var size = This.recSize;
if (!size) {
err('未采集到录音');
return;
}
if (!This.buffers[0]) {
err('音频buffers被释放');
return;
}
if (!This[set.type]) {
err('未加载' + set.type + '编码器');
return;
}
//环境配置检查,此处仅针对mock调用,因为open已经检查过了
if (This.isMock) {
var checkMsg = This.envCheck(
This.mockEnvInfo || { envName: 'mock', canProcess: false }
); //没有提供环境信息的mock时没有onProcess回调
if (checkMsg) {
err('录音错误:' + checkMsg);
return;
}
}
//此类型有边录边转码(Worker)支持
var engineCtx = This.engineCtx;
if (This[set.type + '_complete'] && engineCtx) {
var duration = Math.round(View on GitHub (pinned to 5e758547a8)