Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Fix] loudness: prevent NaN when all blocks are below absolute threshold#4110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Az-CMQ wants to merge1 commit intopytorch:main
base:main
Choose a base branch
Loading
fromAz-CMQ:main

Conversation

@Az-CMQ
Copy link

Background

Theloudness() function intorchaudio.functional implements the ITU-R BS.1770-4 loudness measurement. It applies both absolute and relative gating to compute energy-averaged LKFS values.

Issue

When all audio blocks are below the absolute gating threshold (gamma_abs = -70), the computation ofenergy_filtered involves division by the count of gated blocks, which is zero in this scenario. This results in a NaN output. This edge case commonly occurs for very quiet or silent audio signals.

Changes

  • Introducedtorch.where to safely handle cases where the count of gated blocks is zero.
  • When no blocks pass the gating threshold,energy_filtered is set to zero.
  • Separate variables (abs_gated_blocks andrel_gated_blocks) are used to clearly distinguish absolute and relative gating steps.
  • Maintained compatibility with ITU-R BS.1770-4 standard for normal audio signals.

Impact

  • Prevents NaN values for extremely low-level signals.
  • No change in behavior for signals with blocks above the threshold.
  • Safe for both CPU and CUDA devices.

@Az-CMQAz-CMQ requested a review froma team as acode ownerSeptember 14, 2025 04:40
@pytorch-bot
Copy link

pytorch-botbot commentedSep 14, 2025
edited
Loading

🔗 Helpful Links

🧪 See artifacts and rendered test results athud.pytorch.org/pr/pytorch/audio/4110

Note: Links to docs will display an error until the docs builds have been completed.

❌ 1 New Failure

As of commit35c7f31 with merge base87ff22e (image):

NEW FAILURE - The following job has failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@Az-CMQ

[8]ページ先頭

©2009-2025 Movatter.jp