Skip to content

Conversation

@vincentqb
Copy link
Contributor

Following comment, setting dither to 0 and setting energy_floor to 1..

import torchaudio

filename = "audio/test/assets/steam-train-whistle-daniel_simon.mp3"
s, sr = torchaudio.load(filename)

spec1 = torchaudio.compliance.kaldi.spectrogram(s, dither=0., energy_floor=1.)
spec2 = torchaudio.compliance.kaldi.spectrogram(s, dither=1e-6)
print(2*((spec1 - spec2).abs()/(spec1.abs() + spec2.abs())).mean())
# tensor(0.0016)  # Mean absolute percent difference 

spec1 = torchaudio.compliance.kaldi.fbank(s, dither=0., energy_floor=1.)
spec2 = torchaudio.compliance.kaldi.fbank(s, dither=1e-6)
print(2*((spec1 - spec2).abs()/(spec1.abs() + spec2.abs())).mean())
# tensor(4.8548e-05)

spec1 = torchaudio.compliance.kaldi.mfcc(s, dither=0., energy_floor=1.)
spec2 = torchaudio.compliance.kaldi.mfcc(s, dither=1e-6)
print(2*((spec1 - spec2).abs()/(spec1.abs() + spec2.abs())).mean())
# tensor(0.0022)

Closes #371

@vincentqb vincentqb self-assigned this Mar 3, 2020
Copy link

@zhangguanheng66 zhangguanheng66 left a comment

Choose a reason for hiding this comment

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

Update docs?

@vincentqb
Copy link
Contributor Author

Update docs?

Thanks, good catch! Updated.

@vincentqb vincentqb merged commit e108fe2 into pytorch:master Mar 6, 2020
mthrok pushed a commit to mthrok/audio that referenced this pull request Feb 26, 2021
Changed the name of former torchies nn_tutorial
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.

Dithering constant

2 participants