Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions egs/librispeech/ASR/local/compute_fbank_librispeech.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def compute_fbank_librispeech(
recordings=m["recordings"],
supervisions=m["supervisions"],
)

# Resample audio to 16kHz to match Fbank extractor's expected sampling rate
logging.info(f"Resampling audio to 16000 Hz")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Drop the unused f-string prefix.

This log line has no placeholders, so the f prefix is redundant and triggers F541.

🔧 Proposed fix
-            logging.info(f"Resampling audio to 16000 Hz")
+            logging.info("Resampling audio to 16000 Hz")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logging.info(f"Resampling audio to 16000 Hz")
logging.info("Resampling audio to 16000 Hz")
🧰 Tools
🪛 Ruff (0.14.13)

134-134: f-string without any placeholders

Remove extraneous f prefix

(F541)

🤖 Prompt for AI Agents
In `@egs/librispeech/ASR/local/compute_fbank_librispeech.py` at line 134, The
logging call using an unnecessary f-string should be changed to a normal string
literal: update the logging.info call in compute_fbank_librispeech.py (the line
that currently reads logging.info(f"Resampling audio to 16000 Hz")) to remove
the leading "f" so it becomes logging.info("Resampling audio to 16000 Hz"); this
eliminates the unused f-string prefix and resolves the F541 lint warning while
keeping the same log message.

cut_set = cut_set.resample(16000)
Comment on lines +134 to +135

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The sampling rate 16000 is used as a magic number in both the log message and the resample call. It's a good practice to define such values as constants to improve code readability and maintainability. This makes it easier to find and change the value if needed in the future.

For example:

SAMPLING_RATE = 16000
logging.info(f"Resampling audio to {SAMPLING_RATE} Hz")
cut_set = cut_set.resample(SAMPLING_RATE)

Ideally, this constant would be defined at a broader scope (e.g., at the top of the function) and also used when creating the Fbank extractor on line 119 to ensure consistency.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain which error this is fixing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertionError: Fbank was instantiated for sampling_rate 16000, but sampling_rate=8000 was passed to extract().

There was mismatch in the sampling rate when some audios are not recorded in 16000 Hz

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it your own data?

All data from librispeech has a sample rate 16000 Hz.

@Prithwin55 Prithwin55 Jan 20, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well i was using a custom dataset!


if "train" in partition:
if bpe_model:
Expand Down
Loading