Convert the frequency representaiton of a signal in Hz into the mel scale. Parameters ---------- hz : :py:class:`ndarray ` of shape `(N, \*)` The frequencies of the items in `mel`, in Hz formula : {"htk", "slaney"} The Mel formula to use. "htk" us
(hz, formula="htk")
| 743 | |
| 744 | |
| 745 | def hz2mel(hz, formula="htk"): |
| 746 | """ |
| 747 | Convert the frequency representaiton of a signal in Hz into the mel scale. |
| 748 | |
| 749 | Parameters |
| 750 | ---------- |
| 751 | hz : :py:class:`ndarray <numpy.ndarray>` of shape `(N, \*)` |
| 752 | The frequencies of the items in `mel`, in Hz |
| 753 | formula : {"htk", "slaney"} |
| 754 | The Mel formula to use. "htk" uses the formula used by the Hidden |
| 755 | Markov Model Toolkit, and described in O'Shaughnessy (1987). "slaney" |
| 756 | uses the formula used in the MATLAB auditory toolbox (Slaney, 1998). |
| 757 | Default is 'htk'. |
| 758 | |
| 759 | Returns |
| 760 | ------- |
| 761 | mel : :py:class:`ndarray <numpy.ndarray>` of shape `(N, \*)` |
| 762 | An array of mel frequencies to convert. |
| 763 | """ |
| 764 | fstr = "formula must be either 'htk' or 'slaney' but got '{}'" |
| 765 | assert formula in ["htk", "slaney"], fstr.format(formula) |
| 766 | |
| 767 | if formula == "htk": |
| 768 | return 2595 * np.log10(1 + hz / 700) |
| 769 | raise NotImplementedError("slaney") |
| 770 | |
| 771 | |
| 772 | def mel_filterbank( |