Skip to content

Commit 533f874

Browse files
ravicodelabsfacebook-github-bot
authored andcommitted
Added example for MFCC transform (#2637)
Summary: Added example for MFCC transform as mentioned in issue #1564. Note: Python formatter package `black` uses double quotes for the string dict keys (e.g. in `melkwargs` for this example). Please let me know if there is a different linter/format/convention that is preferred! Pull Request resolved: #2637 Reviewed By: carolineechen Differential Revision: D38873729 Pulled By: nateanl fbshipit-source-id: 2e8fe2930671e7c5d02c0c37cf1ca5cc8c5079e3
1 parent 789adf0 commit 533f874

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

torchaudio/transforms/_transforms.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,15 @@ class MFCC(torch.nn.Module):
667667
log_mels (bool, optional): whether to use log-mel spectrograms instead of db-scaled. (Default: ``False``)
668668
melkwargs (dict or None, optional): arguments for MelSpectrogram. (Default: ``None``)
669669
670+
Example
671+
>>> waveform, sample_rate = torchaudio.load("test.wav", normalize=True)
672+
>>> transform = transforms.MFCC(
673+
>>> sample_rate=sample_rate,
674+
>>> n_mfcc=13,
675+
>>> melkwargs={"n_fft": 400, "hop_length": 160, "n_mels": 23, "center": False},
676+
>>> )
677+
>>> mfcc = transform(waveform)
678+
670679
See also:
671680
:py:func:`torchaudio.functional.melscale_fbanks` - The function used to
672681
generate the filter banks.

0 commit comments

Comments
 (0)