iflytek/astron-agent · error · BusinessException

AUDIO_BIT_DEPTH_INVALID

AUDIO_BIT_DEPTH_INVALID

Error message

AUDIO_BIT_DEPTH_INVALID

What it means

BusinessException(ResponseEnum.AUDIO_BIT_DEPTH_INVALID) thrown by getAudioFormat when format.getSampleSizeInBits() != REQUIRED_SAMPLE_SIZE (16 bits). The service accepts only 16-bit PCM audio, so 8-bit, 24-bit, or 32-bit float files are rejected during format extraction.

Solutions

  1. Convert to 16-bit PCM with ffmpeg: ffmpeg -i in.wav -c:a pcm_s16le out.wav.
  2. Re-export from the audio editor choosing 16-bit PCM as the encoding.
  3. When recording, set the device depth to 16-bit.
  4. Verify with ffprobe that the file reports 'pcm_s16le' / 16 bits per sample before uploading.

Example fix

// before: 24-bit master rejected
upload(master_24bit.wav)
// after: convert to 16-bit PCM
// ffmpeg -i master_24bit.wav -c:a pcm_s16le master_16bit.wav
upload(master_16bit.wav)
Defensive patterns

Strategy: validation

Validate before calling

// ffprobe -v error -show_entries stream=codec_name,bits_per_sample -of csv=p=0 file.wav  -> expect pcm_s16le / 16

Try / catch

try { AudioValidator.validateAudioProperties(file); }
catch (BusinessException e) { if (ResponseEnum.AUDIO_BIT_DEPTH_INVALID.equals(e.getResponseEnum())) { /* 400: convert to 16-bit PCM */ } else { throw e; } }

Prevention

When it happens

Trigger: Uploading WAV/PCM audio that is not 16-bit — e.g. 8-bit u-law telephony wav, 24-bit studio recordings, or 32-bit float exports — to the endpoint whose format path calls getAudioFormat.

Common situations: Studio masters exported at 24-bit/96kHz; 8-bit legacy recordings; float WAVs from DAW exports; conversions that preserved original bit depth instead of down-converting.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

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

    }

    @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();

        // Rough estimate: 16bit mono 24kHz audio is approximately 48KB per second
        // 40 seconds of audio is approximately 1.92MB, leaving some margin
        long estimatedMaxSizeForDuration = (long) (MAX_DURATION_SECONDS * 48000 * 1.5);

        if (fileSize > estimatedMaxSizeForDuration) {

View on GitHub (pinned to 5e758547a8)