iflytek/astron-agent · error
未采集到录音
Error message
未采集到录音
What it means
Recorder-Core's stop() checks This.recSize before encoding and errors when zero audio data was collected — the recorder ran (or was asked to stop) but never accumulated any PCM samples, so there is nothing to encode.
Solutions
- Wait until onProcess has delivered data (or a small delay) after start() before calling stop().
- Verify the microphone device is present, unmuted, and permission granted.
- Ensure start() was called in a user-gesture handler so AudioContext is running.
- Check rec.state and recSize before stop: only stop when recSize > 0.
- If streaming chunks via takeoffEncodeChunk, remember data leaves via the worker path and stop-time size checks may legitimately see zero.
Example fix
// before
rec.start();
rec.stop(); // error: no samples yet
// after
rec.start();
setTimeout(function() {
if (rec.recSize > 0) rec.stop();
}, 1000); Defensive patterns
Strategy: validation
Validate before calling
function safeStop(rec, cb) {
if (!rec || rec.recSize === 0) { showToast('No audio captured'); return; }
rec.stop(cb);
} Type guard
function hasAudioData(rec) { return !!rec && rec.recSize > 0; } Try / catch
rec.stop(function(blob) { ... }); // plus pre-check:
if (!hasAudioData(rec)) { showToast('未采集到录音,请重新录制'); return; } Prevention
- Wait for onProcess data (or a delay) after start() before stopping.
- Check mic permission and device availability before opening.
- Start recording within a user gesture to keep AudioContext running.
- Track recSize in UI and disable stop until data exists.
When it happens
Trigger: rec.stop() is called when This.recSize is 0, i.e. no onProcess buffers arrived: start() was never effective, capture was stalled, or stop happened before the first audio chunk.
Common situations: Calling stop() immediately after start() (same tick); microphone captured silence due to a muted/disconnected device while frames never flushed; browser suspended audio processing without a user gesture; isMock environment without a processing env configured.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/2c8375160626e9f6.
Report an issue: GitHub.
Appendix: source
Thrown at console/frontend/src/utils/record/recorder-core.js:1383
}
True &&
True(blob, duration, originBUffers || [], originSampleRate || 44100);
end();
};
if (!This.isMock) {
var isCtxWait = This.state == 3;
if (!This.state || isCtxWait) {
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);View on GitHub (pinned to 5e758547a8)