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
Migrate kaldi mfcc #681
Migrate kaldi mfcc #681
Conversation
Signed-off-by: Bhargav Kathivarapu <bhargavkathivarapu31@gmail.com>
Can you apply this patch? diff --git a/torchaudio/compliance/kaldi.py b/torchaudio/compliance/kaldi.py
index 8115c3a..bdf5f40 100644
--- a/torchaudio/compliance/kaldi.py
+++ b/torchaudio/compliance/kaldi.py
@@ -696,6 +696,8 @@ def mfcc(
"""
assert num_ceps <= num_mel_bins, 'num_ceps cannot be larger than num_mel_bins: %d vs %d' % (num_ceps, num_mel_bins)
+ device, dtype = waveform.device, waveform.dtype
+
# The mel_energies should not be squared (use_power=True), not have mean subtracted
# (subtract_mean=False), and use log (use_log_fbank=True).
# size (m, num_mel_bins + use_energy)
@@ -717,7 +719,7 @@ def mfcc(
feature = feature[:, mel_offset:(num_mel_bins + mel_offset)]
# size (num_mel_bins, num_ceps)
- dct_matrix = _get_dct_matrix(num_ceps, num_mel_bins)
+ dct_matrix = _get_dct_matrix(num_ceps, num_mel_bins).to(dtype=dtype, device=device)
# size (m, num_ceps)
feature = feature.matmul(dct_matrix)
@@ -725,7 +727,7 @@ def mfcc(
if cepstral_lifter != 0.0:
# size (1, num_ceps)
lifter_coeffs = _get_lifter_coeffs(num_ceps, cepstral_lifter).unsqueeze(0)
- feature *= lifter_coeffs
+ feature *= lifter_coeffs.to(device=device, dtype=dtype)
# if use_energy then replace the last column for htk_compat == true else first column
if use_energy: |
Signed-off-by: Bhargav Kathivarapu <bhargavkathivarapu31@gmail.com>
Signed-off-by: Bhargav Kathivarapu <bhargavkathivarapu31@gmail.com>
Signed-off-by: Bhargav Kathivarapu <bhargavkathivarapu31@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #681 +/- ##
=======================================
Coverage 88.72% 88.72%
=======================================
Files 22 22
Lines 2341 2342 +1
=======================================
+ Hits 2077 2078 +1
Misses 264 264
Continue to review full report at Codecov.
|
@mthrok , Applied the kaldi mfcc patch . Removed all assertion failing tests |
Looks great! Thanks! |
Follow up: If you have time, can you remove them too? |
Will remove these in next PR for kaldi migration |
…rial Dynamic quantization tutorial
This PR migrates the kaldi mfcc test (#597 ) from test/test_compliance_kaldi.py to test/kaldi_compatibility_impl.py