iflytek/astron-agent · error · BusinessException

AUDIO_SAMPLE_RATE_TOO_LOW

AUDIO_SAMPLE_RATE_TOO_LOW

Error message

AUDIO_SAMPLE_RATE_TOO_LOW

What it means

BusinessException(ResponseEnum.AUDIO_SAMPLE_RATE_TOO_LOW) thrown by getAudioFormat when format.getSampleRate() is below MIN_SAMPLE_RATE (24kHz). The service requires voice-quality audio at 24kHz or higher, so low-rate recordings are rejected after the channel check.

Solutions

  1. Resample to at least 24kHz with ffmpeg: ffmpeg -i low.wav -ar 24000 resampled.wav (note: upsampled audio adds no information but passes the gate).
  2. Re-record at 24kHz+ — set the capture device/app sample rate to 24000 or 48000 Hz.
  3. Export from the audio editor with sample rate >= 24000 Hz.
  4. Check the current requirement (MIN_SAMPLE_RATE in AudioValidator) before exporting.

Example fix

// before: 8kHz telephony recording rejected
upload(call_8k.wav)
// after: resample to 24kHz+
// ffmpeg -i call_8k.wav -ar 24000 call_24k.wav
upload(call_24k.wav)
Defensive patterns

Strategy: validation

Validate before calling

// ffprobe -v error -show_entries stream=sample_rate -of csv=p=0 file.wav  -> expect >= 24000

Try / catch

try { AudioValidator.validateAudioProperties(file); }
catch (BusinessException e) { if (ResponseEnum.AUDIO_SAMPLE_RATE_TOO_LOW.equals(e.getResponseEnum())) { /* 400: ask user to resample >= 24kHz */ } else { throw e; } }

Prevention

When it happens

Trigger: Uploading WAV/PCM audio sampled below 24000 Hz — e.g. 8kHz telephone-quality recordings or 16kHz speech corpora — to the endpoint that runs getAudioFormat via validateAudioProperties/format.

Common situations: Legacy telephony recordings (8kHz); speech datasets exported at 16kHz; recorder apps configured for small files at low sample rates; conversions that downsampled the audio.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/0b717e18bbcb192e. Report an issue: GitHub.

Appendix: source

Thrown at console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java:142

                if (durationSeconds > MAX_DURATION_SECONDS) {
                    throw new BusinessException(ResponseEnum.AUDIO_DURATION_TOO_LONG);
                }
            }
        }
    }

    @NotNull
    private static AudioFormat getAudioFormat(AudioInputStream audioInputStream) {
        AudioFormat format = audioInputStream.getFormat();

        // Check number of channels (mono)
        if (format.getChannels() != REQUIRED_CHANNELS) {
            throw new BusinessException(ResponseEnum.AUDIO_CHANNELS_INVALID);
        }

        // Check sample rate (24kHz and above)
        if (format.getSampleRate() < MIN_SAMPLE_RATE) {
            throw new BusinessException(ResponseEnum.AUDIO_SAMPLE_RATE_TOO_LOW);
        }

        // Check bit depth (16bit)
        if (format.getSampleSizeInBits() != REQUIRED_SAMPLE_SIZE) {
            throw new BusinessException(ResponseEnum.AUDIO_BIT_DEPTH_INVALID);
        }
        return format;
    }

    /**
     * Validate basic properties for MP3 and M4A formats
     */
    private static void validateMp3M4aBasic(MultipartFile file) throws BusinessException {
        // For MP3 and M4A, only basic validation can be performed currently
        // Duration check is roughly estimated by file size (this is not a precise method, but it is a
        // reasonable approximation without specialized libraries)
        long fileSize = file.getSize();

View on GitHub (pinned to 5e758547a8)