spafe.utils.converters¶
-
spafe.utils.converters.
bark2fft
(fb, fs, nfft)[source]¶ Convert Bark frequencies to fft bins.
Parameters: - fb (np.array) – frequencies in Bark [Bark].
- fs (int) – sample rate/ sampling frequency of the signal.
- nfft (int) – the FFT size.
Returns: fft bin numbers.
Return type: (np.array)
-
spafe.utils.converters.
bark2hz
(fb)[source]¶ Convert Bark frequencies to Hz.
Parameters: fb (np.array) – input frequencies [Bark]. Returns: frequencies in Hz [Hz]. Return type: (np.array)
-
spafe.utils.converters.
erb2fft
(fb, fs, nfft)[source]¶ Convert Bark frequencies to fft bins.
Parameters: - fb (np.array) – frequencies in Bark [Bark].
- fs (int) – sample rate/ sampling frequency of the signal.
- nfft (int) – the FFT size.
Returns: fft bin numbers.
Return type: (np.array)
-
spafe.utils.converters.
erb2hz
(fe)[source]¶ Convert Bark frequencies to Hz.
Parameters: fb (np.array) – input frequencies [Bark]. Returns: frequencies in Hz [Hz]. Return type: (np.array)
-
spafe.utils.converters.
fft2bark
(fft, fs, nfft)[source]¶ Convert Bark frequencies to Hz.
Parameters: - fft (np.array) – fft bin numbers.
- fs (int) – sample rate/ sampling frequency of the signal.
- nfft (int) – the FFT size.
Returns: frequencies in Bark [Bark].
Return type: (np.array)
-
spafe.utils.converters.
fft2barkmx
(nfft, fs, nfilts=0, bwidth=1, low_freq=0, high_freq=0)[source]¶ Generate a matrix of weights to combine FFT bins into Bark bins.
Parameters: - nfft (int) – the FFT size. (Default is 512)
- fs (int) – sample rate/ sampling frequency of the signal. (Default 16000 Hz)
- nfilts (int) – the number of filters in the filterbank. (Default 20)
- bwidth (int) – the constant width of each band relative to standard Mel (default 1). Default is 1.
- low_freq (int) – lowest band edge of mel filters. (Default 0 Hz)
- high_freq (int) – highest band edge of mel filters. (Default sample rate/2)
Notes
Optional nfilts specifies the number of output bands required (else one per bark), and width is the constant width of each band in Bark (default 1).
Returns: matrix of weights to combine FFT bins into Bark bins.
-
spafe.utils.converters.
fft2erb
(fft, fs, nfft)[source]¶ Convert Bark frequencies to Hz.
Parameters: fft (np.array) – fft bin numbers. Returns: frequencies in Bark [Bark]. Return type: (np.array)
-
spafe.utils.converters.
fft2hz
(fft, fs, nfft)[source]¶ Convert Bark frequencies to Hz.
Parameters: - fft (np.array) – fft bin numbers.
- fs (int) – sample rate/ sampling frequency of the signal.
- nfft (int) – the FFT size.
Returns: frequencies in Bark [Bark].
Return type: (np.array)
-
spafe.utils.converters.
fft2melmx
(nfft, fs, nfilts=0, bwidth=1, low_freq=0, high_freq=0, htk=False, constamp=False)[source]¶ Generate a matrix of weights to combine FFT bins into Mel bins.
Parameters: - nfft (int) – the FFT size. (Default is 512)
- fs (int) – sample rate/ sampling frequency of the signal. (Default 16000 Hz)
- nfilts (int) – the number of filters in the filterbank. (Default 20)
- bwidth (int) – the constant width of each band relative to standard Mel (default 1). Default is 1.
- low_freq (int) – lowest band edge of mel filters. (Default 0 Hz)
- high_freq (int) – highest band edge of mel filters. (Default samplerate/2)
- htkmel (bool) – use HTK’s version of the mel curve, not Slaney’s. Default is False.
- constamp (bool) – if True then make integration windows peak at 1, not sum to 1. Default is False.
- Notes
- low_freq default is 0, but 133.33 is a common standard (to skip low frequencies). high_freq default is fs/2 You can exactly duplicate the mel matrix in Slaney’ss using fft2melmx(nfft=512, fs=8000, nfilts=40, bwidth=1, low_freq=133.33, high_freq=6855.5, 0)
Returns: matrix of weights to combine FFT bins into Mel bins.
-
spafe.utils.converters.
hz2bark
(f)[source]¶ Convert Hz frequencies to Bark acoording to Wang, Sekey & Gersho, 1992.
Parameters: f (np.array) – input frequencies [Hz]. Returns: frequencies in Bark [Bark]. Return type: (np.array)
-
spafe.utils.converters.
hz2erb
(f)[source]¶ Convert Hz frequencies to Bark.
Parameters: f (np.array) – input frequencies [Hz]. Returns: frequencies in Bark [Bark]. Return type: (np.array)
-
spafe.utils.converters.
hz2fft
(fb, fs, nfft)[source]¶ Convert Bark frequencies to fft bins.
Parameters: - fb (np.array) – frequencies in Bark [Bark].
- fs (int) – sample rate/ sampling frequency of the signal.
- nfft (int) – the FFT size.
Returns: fft bin numbers.
Return type: (np.array)
-
spafe.utils.converters.
hz2mel
(hz, htk=1)[source]¶ Convert a value in Hertz to Mels
Parameters: - hz – a value in Hz. This can also be a numpy array, conversion proceeds element-wise.
- htk – Optional variable, if htk = 1 uses the mel axis defined in the HTKBook otherwise use Slaney’s formula.
Returns: a value in Mels. If an array was passed in, an identical sized array is returned.
-
spafe.utils.converters.
mel2hz
(mel, htk=1)[source]¶ Convert a value in Mels to Hertz
Parameters: - mel – a value in Mels. This can also be a numpy array, conversion proceeds element-wise.
- htk – Optional variable, if htk = 1 uses the mel axis defined in the HTKBook otherwise use Slaney’s formula.
Returns: a value in Hertz. If an array was passed in, an identical sized array is returned.