Skip to content

Fix invalid TimeStretch example in transforms doc#4196

Open
adityasingh2400 wants to merge 1 commit into
pytorch:mainfrom
adityasingh2400:doc-fix-timestretch-example-3438
Open

Fix invalid TimeStretch example in transforms doc#4196
adityasingh2400 wants to merge 1 commit into
pytorch:mainfrom
adityasingh2400:doc-fix-timestretch-example-3438

Conversation

@adityasingh2400
Copy link
Copy Markdown

Summary

docs/source/transforms.rst showed the TimeStretch transform being constructed as:

TimeStretch(stretch_factor, fixed_rate=True)

This is incorrect for two reasons:

  1. TimeStretch.__init__ has no positional stretch_factor parameter. Its signature is TimeStretch(hop_length=None, n_freq=201, fixed_rate=None), so stretch_factor would silently bind to hop_length.
  2. fixed_rate is typed as Optional[float] (the rate to stretch by), not a boolean.

This PR replaces the example with a runnable form that matches the actual signature, using n_freq derived the same way as the MelScale call directly below it (n_fft // 2 + 1), and passing the existing stretch_factor argument as fixed_rate:

TimeStretch(n_freq=n_fft // 2 + 1, fixed_rate=stretch_factor)

Fixes #3438.

Test plan

  • Confirmed TimeStretch signature in src/torchaudio/transforms/_transforms.py: __init__(self, hop_length=None, n_freq=201, fixed_rate=None).
  • Docs-only change; no code paths affected.

docs/source/transforms.rst showed TimeStretch(stretch_factor,
fixed_rate=True), but the class signature has no positional
stretch_factor and fixed_rate takes a float, not a bool. Replace
with a runnable example using the actual signature.

Fixes pytorch#3438
@adityasingh2400 adityasingh2400 requested a review from a team as a code owner May 22, 2026 00:41
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented May 22, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/audio/4196

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

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

@meta-cla meta-cla Bot added the CLA Signed label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage of TimeStretch is incorrect in documentation.

1 participant