Initial Checklist
Problem Statement & User Value
As a machine learning engineer, I want to convert standard audio spectrograms into a mel scale representation (mel-spectrogram), so that I can extract features for training deep learning models on tasks like speech recognition, audio classification, and music information retrieval.
Acceptance Criteria (Definition of Done)
Core Functionality
Parameterization & Configuration
Validation & Correctness
Documentation
Proposed Solution or Technical Approach (Optional)
The new functionality should be housed into the Spectral module of SoundML.
- Type Definitions: To ensure type safety and clarity, we should define variant types for the primary configuration options:
type mel_scale = HTK | Slaney
type mel_norm = None | Slaney
- Filterbank Construction: We should try to maximize the use of vectorized operation with Rune. Additional +1 for JIT-compatible implementation. Big picture of the algorithm:
- Calculate the center frequencies of the
n_fft / 2 + 1 FFT bins from 0 Hz to the Nyquist frequency (sample_rate / 2).
- Convert
f_min and f_max from Hz to the selected mel scale (HTK or Slaney).
- Create
n_mels + 2 linearly spaced points in the mel domain between the mel-scaled min and max frequencies.
- Convert these points back to Hz to serve as the start, center, and end points for the triangular filters.
- For each of the
n_mels filters, construct its triangular weights across all FFT frequency bins.
- Apply the specified normalization scheme (
None for peak=1.0, or Slaney for area normalization).
- Mel Spectrogram Computation: This is the simplest step as it require only a matrix multiplication.
- First, the input STFT magnitude spectrogram is raised to the specified power (default 2.0) to get a power spectrogram.
- The mel spectrogram is then computed via a single matrix multiplication of the filterbank matrix and the power spectrogram.
- Logarithmic Scaling (
power_to_db): This utility function will apply the standard decibel conversion: 10 * log10(max(amin, S) / ref).
Additional Context (Mockups, Links, etc.)
No response
References
Code of Conduct
Initial Checklist
Problem Statement & User Value
As a machine learning engineer, I want to convert standard audio spectrograms into a mel scale representation (mel-spectrogram), so that I can extract features for training deep learning models on tasks like speech recognition, audio classification, and music information retrieval.
Acceptance Criteria (Definition of Done)
Core Functionality
power_to_dbis available to convert a power spectrogram to a logarithmic (decibel) scale, which is a standard final step.Parameterization & Configuration
sample_rate,n_fft,n_mels,f_min, andf_max.2.0to convert magnitude to power.power_to_dbfunction must include parameters for numerical stability (amin) and reference-level normalization (ref).Validation & Correctness
hz_to_mel,mel_to_hz) for both HTK and Slaney scales.Documentation
Proposed Solution or Technical Approach (Optional)
The new functionality should be housed into the
Spectralmodule of SoundML.n_fft / 2 + 1FFT bins from 0 Hz to the Nyquist frequency (sample_rate / 2).f_minandf_maxfrom Hz to the selected mel scale (HTK or Slaney).n_mels + 2linearly spaced points in the mel domain between the mel-scaledminandmaxfrequencies.n_melsfilters, construct its triangular weights across all FFT frequency bins.Nonefor peak=1.0, orSlaneyfor area normalization).power_to_db): This utility function will apply the standard decibel conversion:10 * log10(max(amin, S) / ref).Additional Context (Mockups, Links, etc.)
No response
References
Code of Conduct