MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / hz2mel

Function hz2mel

numpy_ml/preprocessing/dsp.py:745–769  ·  view source on GitHub ↗

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")

Source from the content-addressed store, hash-verified

743
744
745def 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&#x27;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
772def mel_filterbank(

Callers 1

mel_filterbankFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected