Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update feature_extractor.py #1038

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

BBC-Esq
Copy link
Contributor

@BBC-Esq BBC-Esq commented Oct 5, 2024

Added mel filter bank caching to FeatureExtractor class to optimize memory usage and reduce computational overhead when processing multiple audio files with identical parameters, particularly beneficial for batch processing scenarios.

Copy link

@abodacs abodacs left a comment

Choose a reason for hiding this comment

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

@BBC-Esq
Thanks for your work

if padding:
waveform = torch.nn.functional.pad(waveform, (0, self.n_samples))

window = torch.hann_window(self.n_fft).to(waveform.device)
Copy link

Choose a reason for hiding this comment

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

Why was the hann_window deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll take a look...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is actually an optimization. In the old version, a new Hann window was being created and moved to the device every time call was executed. The new version creates it once during initialization and caches it as an instance variable (self.window).

else waveform
)
# Move waveform to the target device if necessary
if self.device == "cuda" and not waveform.is_cuda:
Copy link

Choose a reason for hiding this comment

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

Improved readability, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants