Speech Processing
Lab 2
Outline
• What’s Feature Extraction?
• What’s Librosa?
• Feature Extraction using Librosa
• MFCC
• Mel-Spectrogram
• Phonetic Classification
What’s Feature Extraction?
• Process of converting raw audio signals into a compact set of
numerical features that capture the essential characteristics of
the sound.
• These features provide a compact, robust representation of
key speech attributes—frequency, energy, and temporal
changes—enabling more effective tasks like recognition,
speaker ID, or emotion analysis.
What’s Librosa?
• Python package for music and audio analysis
• It provides the building blocks necessary to create music
information retrieval systems.
What’s Librosa?
• Installing and Importing Librosa
• Loading and Inspecting Audio Files using Librosa
Feature Extraction using
Librosa
• MFCC (Mel-Frequency Cepstral Coefficients)
▪ Features extracted from an audio signal that capture its short-
term power spectrum in a way that reflects human auditory
perception.
▪ How is MFCC Computed :
1. Fourier Transform
2. Mel Scale Mapping
3. Logarithmic Compression
4. Discrete Cosine Transform
Feature Extraction using
Librosa
• MFCC (Mel-Frequency Cepstral Coefficients)
▪ First line Computes the MFCCs from the audio waveform
stored in variable y using the sampling rate sr.
▪ The parameter n_mfcc=13 specifies that 13 MFCC coefficients
will be calculated per frame.
▪ mfccs, is a 2D NumPy array with shape (13, T), where T is the
number of time frames. Each row corresponds to one MFCC
coefficient over time.
Feature Extraction using
Librosa
• MFCC (Mel-Frequency Cepstral Coefficients)
▪ Second line computes the mean of each of the 13 MFCC
coefficient rows across all time frames.
▪ mfccs_mean is a 1D NumPy array of length 13 that summarizes
the overall average value of each MFCC coefficient over the
entire audio clip.
Feature Extraction using
Librosa
• Mel Spectrogram
▪ Time–frequency representation of a sound signal, where:
1. Short-Time Fourier Transform(STFT)
2. Mel-Scale Mapping
3. Power or Amplitude Representation
4. Optional Log or Decibel Conversion
Feature Extraction using
Librosa
• Mel Spectrogram
▪ First line computes the mel spectrogram of the audio signal
stored in audio_data using the provided sampling rate.
▪ mel_spec contains the power spectrogram values on the mel
scale, typically represented as a 2D NumPy array with
dimensions corresponding to the number of mel bands and the
number of time frames.
Feature Extraction using
Librosa
• Mel Spectrogram
▪ Second line converts the mel spectrogram's power values into
decibels (dB) using a logarithmic scale.
▪ ref=[Link], The reference value is set to the maximum power
in the spectrogram. This means that the highest value in
mel_spec becomes 0 dB, and all other values are scaled
relative to this maximum.
▪ mel_spec_db holds the decibel-scaled mel spectrogram, which
is often used for visualization (e.g., plotting with a color map)
or as input to further processing steps.
Phonetic Classification
• The process of assigning segments of speech to discrete sound
categories (phonemes).
• Crucial building block for tasks such as automatic speech
recognition (ASR) and language learning applications.
• The goal is to determine which phonetic unit is being spoken
from a continuous audio signal.
Phonetic Classification
• Steps for Phonetic Classification Task:
1. Data Collection and Labeling
2. Preprocessing
3. Feature Extraction
4. Data Preparation
5. Model Selection and Training
6. Evaluation
Thank You ☺