fix(voice): reject non-positive audio frame rates - #4383
Closed
hsusul wants to merge 1 commit into
Closed
Conversation
_buffer_to_audio_file validates sample width, dtype, channel count, and frame completeness, but not the frame rate. A frame rate of 0 or a negative value reached wave.setframerate and surfaced as a low-level wave.Error rather than the UserError contract the other input validations raise. Reject a non-positive frame rate up front so the failure is consistent and actionable.
4 tasks
Member
|
Closing this PR for the reason I mentioned at #4382 (review) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_buffer_to_audio_fileinagents/voice/input.pyvalidates the sample width, buffer dtype, channel count, and multichannel frame completeness, and raisesUserErrorfor each. It does not validate the frame rate. Aframe_rateof0or a negative value passes straight towave.setframerate, so the caller sees a low-levelwave.Error("sampling rate not specified") instead of theUserErrorthe sibling validations raise. This adds an up-frontframe_rate <= 0check so a bad sample rate fails the same consistent, actionable way, completing the input validation added in #4361, #4370, and #4372.Test plan
Added
test_audio_input_rejects_non_positive_frame_rateintests/voice/test_input.py, parametrized over0and-8000, mirroring the existing non-positive-channels test. It assertsAudioInput.to_audio_file()raisesUserErrormatching "Frame rate must be greater than zero". The test fails onmain(awave.Errorleaks) and passes with this change. The fulltests/voice/test_input.pysuite stays green.Issue number
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR