{"record":{"id":"ff5fe09f0d9f94df","repo":"iflytek/astron-agent","slug":"audio-bit-depth-invalid","errorCode":"AUDIO_BIT_DEPTH_INVALID","errorMessage":"AUDIO_BIT_DEPTH_INVALID","messagePattern":"AUDIO_BIT_DEPTH_INVALID","errorType":"validation","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java","lineNumber":147,"sourceCode":"    }\n\n    @NotNull\n    private static AudioFormat getAudioFormat(AudioInputStream audioInputStream) {\n        AudioFormat format = audioInputStream.getFormat();\n\n        // Check number of channels (mono)\n        if (format.getChannels() != REQUIRED_CHANNELS) {\n            throw new BusinessException(ResponseEnum.AUDIO_CHANNELS_INVALID);\n        }\n\n        // Check sample rate (24kHz and above)\n        if (format.getSampleRate() < MIN_SAMPLE_RATE) {\n            throw new BusinessException(ResponseEnum.AUDIO_SAMPLE_RATE_TOO_LOW);\n        }\n\n        // Check bit depth (16bit)\n        if (format.getSampleSizeInBits() != REQUIRED_SAMPLE_SIZE) {\n            throw new BusinessException(ResponseEnum.AUDIO_BIT_DEPTH_INVALID);\n        }\n        return format;\n    }\n\n    /**\n     * Validate basic properties for MP3 and M4A formats\n     */\n    private static void validateMp3M4aBasic(MultipartFile file) throws BusinessException {\n        // For MP3 and M4A, only basic validation can be performed currently\n        // Duration check is roughly estimated by file size (this is not a precise method, but it is a\n        // reasonable approximation without specialized libraries)\n        long fileSize = file.getSize();\n\n        // Rough estimate: 16bit mono 24kHz audio is approximately 48KB per second\n        // 40 seconds of audio is approximately 1.92MB, leaving some margin\n        long estimatedMaxSizeForDuration = (long) (MAX_DURATION_SECONDS * 48000 * 1.5);\n\n        if (fileSize > estimatedMaxSizeForDuration) {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java#L129-L165","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Convert to 16-bit PCM with ffmpeg: ffmpeg -i in.wav -c:a pcm_s16le out.wav.","Re-export from the audio editor choosing 16-bit PCM as the encoding.","When recording, set the device depth to 16-bit.","Verify with ffprobe that the file reports 'pcm_s16le' / 16 bits per sample before uploading."],"exampleFix":"// before: 24-bit master rejected\nupload(master_24bit.wav)\n// after: convert to 16-bit PCM\n// ffmpeg -i master_24bit.wav -c:a pcm_s16le master_16bit.wav\nupload(master_16bit.wav)","handlingStrategy":"validation","validationCode":"// ffprobe -v error -show_entries stream=codec_name,bits_per_sample -of csv=p=0 file.wav  -> expect pcm_s16le / 16","typeGuard":null,"tryCatchPattern":"try { AudioValidator.validateAudioProperties(file); }\ncatch (BusinessException e) { if (ResponseEnum.AUDIO_BIT_DEPTH_INVALID.equals(e.getResponseEnum())) { /* 400: convert to 16-bit PCM */ } else { throw e; } }","preventionTips":["Export as 16-bit PCM (pcm_s16le).","Convert non-16-bit sources with ffmpeg -c:a pcm_s16le.","Set capture devices to 16-bit depth.","Verify bit depth via ffprobe before upload."],"tags":["java","audio","wav","bit-depth"],"backgroundTag":"invalid-argument-value","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}