Skip to content

fix: validate audio sample rates - #6506

Open
fallintoplace wants to merge 1 commit into
google:mainfrom
fallintoplace:fix/audio-sample-rate-validation
Open

fix: validate audio sample rates#6506
fallintoplace wants to merge 1 commit into
google:mainfrom
fallintoplace:fix/audio-sample-rate-validation

Conversation

@fallintoplace

Copy link
Copy Markdown

Summary

  • match rate only as a complete, case-insensitive MIME parameter
  • reject non-positive source and destination sample rates before returning or resampling
  • cover zero-rate inputs, bitrate parameters, and uppercase RATE parameters

Why

parse_sample_rate previously treated rate= as an arbitrary substring, so parameters such as bitrate=128000 could be interpreted as sample rates. It also accepted zero, which could reach a division by zero in resample_pcm16. Direct calls with a zero destination rate had the same problem.

Rejecting invalid rates explicitly avoids silently producing incorrectly pitched or timed audio.

Validation

  • uv run pytest tests/unittests/evaluation/test_audio_utils.py -q
  • uv run pre-commit run --files src/google/adk/evaluation/_audio_utils.py tests/unittests/evaluation/test_audio_utils.py

@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants