.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/mel_mfcc/plot_mfcc.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_mel_mfcc_plot_mfcc.py: MFCC ==== Mel-frequency cepstral coefficients with first-order deltas, the usual input to classic speech and music classifiers. .. GENERATED FROM PYTHON SOURCE LINES 8-14 .. code-block:: Python import matplotlib.pyplot as plt import audio_samples as aus from audio_samples import spectral .. GENERATED FROM PYTHON SOURCE LINES 15-16 Two different harmonic tones in succession give two different coefficient sets. .. GENERATED FROM PYTHON SOURCE LINES 16-21 .. code-block:: Python sr = 22050 first = aus.generation.compound_tone([(220.0, 0.5), (440.0, 0.3), (660.0, 0.2)], 1.0, sr).as_f32() second = aus.generation.compound_tone([(660.0, 0.8), (1320.0, 0.2)], 1.0, sr).as_f32() audio = aus.AudioSamples.concatenate([first, second]) .. GENERATED FROM PYTHON SOURCE LINES 22-23 ``mfcc_frames`` returns ``(channels, n_mfcc, frames)``. .. GENERATED FROM PYTHON SOURCE LINES 23-33 .. code-block:: Python mfcc = audio.mfcc_frames(n_mfcc=13, top_db=80.0)[0] delta = spectral.delta(mfcc) print(mfcc.shape) fig, axes = plt.subplots(2, 1, figsize=(7, 4.5), sharex=True) axes[0].imshow(mfcc, origin="lower", aspect="auto") axes[0].set(ylabel="Coefficient", title="MFCC") axes[1].imshow(delta, origin="lower", aspect="auto") axes[1].set(xlabel="Frame", ylabel="Coefficient", title="Delta") fig.tight_layout() .. image-sg:: /gallery/mel_mfcc/images/sphx_glr_plot_mfcc_001.png :alt: MFCC, Delta :srcset: /gallery/mel_mfcc/images/sphx_glr_plot_mfcc_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (13, 87) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.114 seconds) .. _sphx_glr_download_gallery_mel_mfcc_plot_mfcc.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_mfcc.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_mfcc.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_mfcc.zip `