{"record":{"id":"ed18e554eac239b0","repo":"iflytek/astron-agent","slug":"audio-channels-invalid","errorCode":"AUDIO_CHANNELS_INVALID","errorMessage":"AUDIO_CHANNELS_INVALID","messagePattern":"AUDIO_CHANNELS_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":137,"sourceCode":"            // Check duration (within 40 seconds)\n            long frameLength = audioInputStream.getFrameLength();\n            float frameRate = format.getFrameRate();\n            if (frameRate > 0) {\n                float durationSeconds = frameLength / frameRate;\n                if (durationSeconds > MAX_DURATION_SECONDS) {\n                    throw new BusinessException(ResponseEnum.AUDIO_DURATION_TOO_LONG);\n                }\n            }\n        }\n    }\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 {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/console/backend/commons/src/main/java/com/iflytek/astron/console/commons/util/AudioValidator.java#L119-L155","documentation":"BusinessException(ResponseEnum.AUDIO_CHANNELS_INVALID) thrown by getAudioFormat when the AudioFormat's channel count does not equal REQUIRED_CHANNELS (mono, 1). The service requires single-channel audio, so stereo or multichannel files are rejected during format extraction.","triggerScenarios":"Uploading a stereo (2-channel) or 5.1 WAV/PCM file to the endpoint whose validateAudioProperties path calls getAudioFormat; happens as soon as the stream's format is read, before sample-rate and bit-depth checks.","commonSituations":"Recordings from DAWs or phone mics defaulting to stereo; music tracks (almost always stereo) uploaded instead of voice clips; USB audio interfaces capturing 2 channels; converted files that kept the original channel layout.","solutions":["Downmix to mono with ffmpeg: ffmpeg -i stereo.wav -ac 1 mono.wav.","Set the recorder to single-channel/mono capture before recording.","Re-export from the audio editor with channels = 1 (mono).","Verify the source file is genuinely mono — use ffprobe to check 'Channels: 1'."],"exampleFix":"// before: stereo file rejected\nupload(voice_stereo.wav)\n// after: convert to mono\n// ffmpeg -i voice_stereo.wav -ac 1 voice_mono.wav\nupload(voice_mono.wav)","handlingStrategy":"validation","validationCode":"// check channels before upload via WebAudio or ffprobe\n// ffprobe -v error -show_entries stream=channels -of csv=p=0 file.wav  -> expect 1","typeGuard":null,"tryCatchPattern":"try { AudioValidator.validateAudioProperties(file); }\ncatch (BusinessException e) { if (ResponseEnum.AUDIO_CHANNELS_INVALID.equals(e.getResponseEnum())) { /* 400: request mono downmix */ } else { throw e; } }","preventionTips":["Set recorders/mics to mono capture.","Downmix with ffmpeg -ac 1 before uploading.","Verify with ffprobe that Channels: 1.","Publish the mono requirement in upload docs/UI."],"tags":["java","audio","wav","channels"],"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"}