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

Add psd method to torchaudio.functional #2227

Closed
wants to merge 11 commits into from

Conversation

nateanl
Copy link
Member

@nateanl nateanl commented Feb 15, 2022

This PR adds psd method to torchaudio.functional.
It computes the power spectral density (PSD) matrix of the complex-valued spectrum.
The method also supports normalization of Time-Frequency mask.

torchaudio/functional/functional.py Outdated Show resolved Hide resolved
torchaudio/functional/functional.py Outdated Show resolved Hide resolved
torchaudio/functional/functional.py Outdated Show resolved Hide resolved
@nateanl nateanl changed the title Add compute_power_spectral_density_matrix to torchaudio.functional Add psd method to torchaudio.functional Feb 17, 2022
docs/source/functional.rst Outdated Show resolved Hide resolved
@@ -617,6 +617,29 @@ def test_phase_vocoder(self):
)[..., None]
self._assert_consistency_complex(F.phase_vocoder, (tensor, rate, phase_advance))

def test_psd(self):
def func(specgram):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this helper function required?

IIRC, the reason why the helper function was introduced in other tests is that the helper method does not accept args and kwargs because scripted-function do not support them.
From that viewpoint, this helper function is not required.

Copy link
Member Author

Choose a reason for hiding this comment

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

My experience is that if not using helper function, the arguments with default values need to be given explicitly. In that case, is it good to put all arguments in the inputs?

@@ -582,6 +583,35 @@ def test_rnnt_loss_costs_and_gradients_random_data_with_numpy_fp32(self):
ref_costs, ref_gradients = rnnt_utils.compute_with_numpy_transducer(data=data)
self._test_costs_and_gradients(data=data, ref_costs=ref_costs, ref_gradients=ref_gradients)

def test_psd(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a docstring?

@facebook-github-bot
Copy link
Contributor

@nateanl has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@nateanl has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@nateanl nateanl deleted the refactor_mvdr_0 branch March 1, 2022 20:54
xiaohui-zhang pushed a commit to xiaohui-zhang/audio that referenced this pull request May 4, 2022
Summary:
This PR adds ``psd`` method to ``torchaudio.functional``.
It computes the power spectral density (PSD) matrix of the complex-valued spectrum.
The method also supports normalization of Time-Frequency mask.

Pull Request resolved: pytorch#2227

Reviewed By: mthrok

Differential Revision: D34473908

Pulled By: nateanl

fbshipit-source-id: c1cfc584085d77881b35d41d76d39b26fca1dda9
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.

4 participants