# Extract MFCC Features from Audio

Extract MFCC features from audio as CSV, TSV, or JSON. Tune speech defaults, librosa-style settings, deltas, and sample-rate options locally.

## Run it

- **CLI:** `gizza tool mfcc-extractor 'url=https://example.com/input' 'input_format=base64' 'output=csv' 'n_mfcc=13' 'n_mels=26' 'frame_ms=25' 'hop_ms=10' 'fmin=0' 'fmax=0' 'window=hamming' 'preemphasis=0.97' 'lifter=22' 'mel_scale=htk' 'append_energy=true' 'deltas=none' 'include_time=true' 'decimals=6' 'resample_hz=0'`
- **Web:** https://gizza.ai/tools/mfcc-extractor/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/mfcc-extractor/tool.json

## Inputs

- `input` — Audio file _(file; accept: audio/*)_
- `input_format` — Input encoding _(field)_
- `output` — Output format _(field)_
- `n_mfcc` — MFCC coefficients _(field)_
- `n_mels` — Mel filters _(field)_
- `frame_ms` — Frame length (ms) _(field)_
- `hop_ms` — Hop length (ms) _(field)_
- `fmin` — Low frequency (Hz) _(field)_
- `fmax` — High frequency (Hz, 0 = Nyquist) _(field)_
- `window` — Analysis window _(field)_
- `preemphasis` — Pre-emphasis _(field)_
- `lifter` — Cepstral lifter _(field)_
- `mel_scale` — Mel scale _(field)_
- `append_energy` — Replace C0 with log energy _(field)_
- `deltas` — Derivative features _(field)_
- `include_time` — Include time_s column _(field)_
- `decimals` — Decimal places _(field)_
- `resample_hz` — Analysis sample rate (Hz, 0 = native) _(field)_

## Output

- MFCC matrix (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `input_format` — Input encoding
- `output` — Output format
- `n_mfcc` — MFCC coefficients
- `n_mels` — Mel filters
- `frame_ms` — Frame length (ms)
- `hop_ms` — Hop length (ms)
- `fmin` — Low frequency (Hz)
- `fmax` — High frequency (Hz, 0 = Nyquist)
- `window` — Analysis window
- `preemphasis` — Pre-emphasis
- `lifter` — Cepstral lifter
- `mel_scale` — Mel scale
- `append_energy` — Replace C0 with log energy
- `deltas` — Derivative features
- `include_time` — Include time_s column
- `decimals` — Decimal places
- `resample_hz` — Analysis sample rate (Hz, 0 = native)
- `url` — fetch the input file from a public URL (CORS-permitting)

Example: `https://gizza.ai/tools/mfcc-extractor/?url=https://example.com/input&input_format=base64&output=csv&n_mfcc=13&n_mels=26&frame_ms=25&hop_ms=10&fmin=0&fmax=0&window=hamming&preemphasis=0.97&lifter=22&mel_scale=htk&append_energy=true&deltas=none&include_time=true&decimals=6&resample_hz=0`

---

## About this tool

MFCC Extractor turns an audio file into Mel-frequency cepstral coefficients: the compact frame-by-frame feature matrix used by speech recognizers, speaker-ID systems, keyword spotting models, and many audio classifiers. Upload WAV, FLAC, MP3, M4A, OGG, WebM, or another supported audio container and choose whether the result should be CSV, TSV, or JSON metadata plus matrix rows.

The default settings follow the classic speech-feature pipeline: 25 ms frames, 10 ms hop, 13 coefficients, 26 mel filters, 0.97 pre-emphasis, HTK mel spacing, a lifter of 22, and log frame energy in C0. Preset chips switch to a librosa-style setup, add delta and delta-delta features, or widen the analysis for music-like audio.

### Worked example

For a short speech clip, keep the Speech / ASR defaults and upload the audio. The CSV output starts with a header such as:

```text
time_s,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12
0.000,-4.812345,2.103456,...
```

Each row is one complete analysis frame. `time_s` is the frame start time; turn it off when you need only the numeric coefficient matrix. Set `output=json` when you also want the resolved sample rate, frame length, hop length, FFT size, mel scale, and truncation flags.

### Limits and edge cases

- Input audio bytes are capped at 24 MiB before decoding.
- The decoder analyzes at most 4,000,000 mono samples and reports truncation in JSON output.
- Output is capped at 200,000 frames so tiny hops do not create oversized CSV files.
- Frames are taken from sample 0 with no centering, reflect padding, or zero-padded tail frame.
- DCT-II with orthonormal scaling is used for the cepstral transform; DCT-I/DCT-III and CMVN are separate post-processing steps.
- The log stage uses the natural log of mel energies, not librosa's dB-scaled `power_to_db` reference/max floor.
- Opus, AC-3, and DTS are not decoded by the pure-Rust audio stack; use WAV, FLAC, MP3, AAC/M4A, ALAC, Vorbis/OGG, or PCM-style formats for portable results.

## FAQ

<details>
<summary>What MFCC settings should I use for speech recognition?</summary>

Start with the defaults: 13 coefficients, 26 mel filters, 25 ms frames, 10 ms hop, HTK mel scale, pre-emphasis 0.97, lifter 22, and log energy in C0. If your files have mixed sample rates, set `resample_hz` to 16000 so matrices are comparable.

</details>

<details>
<summary>Why does this not match librosa exactly?</summary>

The defaults are speech-toolkit defaults, while librosa centers frames, uses a Hann window, Slaney mel normalization, larger sample-window settings, and dB-scaled mel power by default. Use the Librosa-style preset to get closer, but this tool still frames from sample 0 and uses natural-log mel energies, so exact equality is not expected.

</details>

<details>
<summary>What do delta and delta-delta columns mean?</summary>

Delta columns estimate how each coefficient changes over nearby frames. Delta-delta columns estimate the change of those deltas. They are common features for acoustic models because they add short-term motion information without changing the original audio.

</details>

<details>
<summary>Can I feed stereo or music files?</summary>

Yes. Stereo and multichannel files are downmixed to mono before analysis. For music-like audio, try more coefficients and filters, a longer frame, Slaney mel scale, and a wider `fmax`; the Wide-band music preset fills those fields.

</details>

## Related tools

- [Shorten Long Audio Pauses](https://gizza.ai/tools/audio-pause-shortener/): Tighten speech pacing by shortening long silent gaps to a natural pause length in your browser. Nothing is uploaded, free.
- [Convert AIFF to FLAC](https://gizza.ai/tools/aiff-to-flac/): Convert AIFF or AIF audio to lossless FLAC in your browser — preserve samples and textual tags, choose FLAC compression level 0-12, and download the result.
- [Bleep or Mute Regions of an Audio File](https://gizza.ai/tools/audio-bleep-censor/): Censor an audio file in your browser — bleep, mute, or duck the exact time regions you pick. Set a tone frequency and output format. Nothing is uploaded, free.
- [Audio Channel Tool](https://gizza.ai/tools/audio-channel/): Swap left/right channels, downmix stereo to mono, up-mix mono to stereo, or copy one side onto both — right in your browser. Nothing is uploaded, free.
- [Compress an Audio File](https://gizza.ai/tools/audio-compress/): Shrink MP3, WAV, M4A or any audio file right in your browser — pick a target bitrate (96 kbps default) and format. Nothing is uploaded, free.
