mistral_common.audio
hertz_to_mel(freq)
Convert frequency from hertz to mels using the "slaney" mel-scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
float | ndarray
|
The frequency, or multiple frequencies, in hertz (Hz). |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
The frequencies on the mel scale. |
Source code in src/mistral_common/audio.py
mel_filter_bank(num_frequency_bins, num_mel_bins, min_frequency, max_frequency, sampling_rate)
cached
Create a Mel filter bank matrix for converting frequency bins to the Mel scale.
This function generates a filter bank matrix that can be used to transform a spectrum represented in frequency bins to the Mel scale. The Mel scale is a perceptual scale of pitches judged by listeners to be equal in distance from one another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_frequency_bins
|
int
|
The number of frequency bins in the input spectrum. |
required |
num_mel_bins
|
int
|
The number of desired Mel bins in the output. |
required |
min_frequency
|
float
|
The minimum frequency (in Hz) to consider. |
required |
max_frequency
|
float
|
The maximum frequency (in Hz) to consider. |
required |
sampling_rate
|
int
|
The sampling rate of the audio signal. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A filter bank matrix of shape (num_mel_bins, num_frequency_bins) |
ndarray
|
that can be used to project frequency bin energies onto Mel bins. |
Source code in src/mistral_common/audio.py
mel_to_hertz(mels)
Convert frequency from mels to hertz using the "slaney" mel-scale.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mels
|
ndarray
|
The frequency, or multiple frequencies, in mels. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The frequencies in hertz. |