mel_weight_matrix#

ivy.mel_weight_matrix(num_mel_bins, dft_length, sample_rate, lower_edge_hertz=0.0, upper_edge_hertz=3000.0)[source]#

Generate a MelWeightMatrix that can be used to re-weight a Tensor containing a linearly sampled frequency spectra (from DFT or STFT) into num_mel_bins frequency information based on the [lower_edge_hertz, upper_edge_hertz]

range on the mel scale. This function defines the mel scale in terms of a frequency in hertz according to the following formula: mel(f) = 2595 * log10(1 + f/700)

Parameters:
  • num_mel_bins (int) – The number of bands in the mel spectrum.

  • dft_length (int) – The size of the original DFT obtained from (n_fft / 2 + 1).

  • sample_rate (int) – Samples per second of the input signal.

  • lower_edge_hertz (float, default: 0.0) – Lower bound on the frequencies to be included in the mel spectrum.

  • upper_edge_hertz (float, default: 3000.0) – The desired top edge of the highest frequency band.

Returns:

ret – MelWeightMatrix of shape: [frames, num_mel_bins].

Examples

>>> ivy.mel_weight_matrix(3,3,8000)
ivy.array([[0.        ,0.        , 0.],
          [0.        ,0. , 0.75694758],
          [0.        ,0. , 0.       ]])
static Array.mel_weight_matrix(num_mel_bins, dft_length, sample_rate, lower_edge_hertz=0.0, upper_edge_hertz=3000.0)[source]#

Generate a MelWeightMatrix that can be used to re-weight a Tensor containing a linearly sampled frequency spectra (from DFT or STFT) into num_mel_bins frequency information based on the [lower_edge_hertz, upper_edge_hertz]

range on the mel scale. This function defines the mel scale in terms of a frequency in hertz according to the following formula: mel(f) = 2595 * log10(1 + f/700)

Parameters:
  • num_mel_bins (Union[int, Array]) – The number of bands in the mel spectrum.

  • dft_length (Union[int, Array]) – The size of the original DFT obtained from (n_fft / 2 + 1).

  • sample_rate (Union[int, Array]) – Samples per second of the input signal.

  • lower_edge_hertz (Optional[Union[float, Array]], default: 0.0) – Lower bound on the frequencies to be included in the mel spectrum.

  • upper_edge_hertz (Optional[Union[float, Array]], default: 3000.0) – The desired top edge of the highest frequency band.

Returns:

ret – MelWeightMatrix of shape: [frames, num_mel_bins].

Examples

>>> x = ivy.array([[1, 2, 3],
>>>                [1, 1, 1],
>>>                [5,6,7  ]])
>>> x.mel_weight_matrix(3, 3, 8000)
ivy.array([[0.        ,0.        , 0.],
          [0.        ,0. , 0.75694758],
          [0.        ,0. , 0.       ]])
Container.mel_weight_matrix(self, num_mel_bins, dft_length, sample_rate, lower_edge_hertz=0.0, upper_edge_hertz=3000.0)[source]#

ivy.Container instance method variant of ivy.mel_weight_matrix. This method simply wraps the function, and so the docstring for ivy.mel_weight_matrix also applies to this method with minimal changes.

Parameters:
  • num_mel_bins (int) – The number of bands in the mel spectrum.

  • dft_length (int) – The size of the original DFT obtained from (n_fft / 2 + 1).

  • sample_rate (int) – Samples per second of the input signal.

  • lower_edge_hertz (Optional[float], default: 0.0) – Lower bound on the frequencies to be included in the mel spectrum.

  • upper_edge_hertz (Optional[float], default: 3000.0) – The desired top edge of the highest frequency band.

Returns:

ret – MelWeightMatrix of shape: [frames, num_mel_bins]