Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The discription of " gammatone_fbanks.gammatone_filter_banks" of document is out of the version #52

Closed
WindDevil opened this issue Dec 5, 2022 · 3 comments · Fixed by #53

Comments

@WindDevil
Copy link

By written in pycharm of the piece of the code in the document, I found that the "return" of the method is not a array of fbanks but a array of "a array of fbanks" and another array that I dont know its mean, I guess it is an array of center frequencies by print it out. Please fix up the document.

@WindDevil
Copy link
Author

I read the source code of the method, and I found that the second member of the return array is a array of center frequncies, but it is ERB frequncies not normal frequncies. There is no description in your document.

@SuperKogito
Copy link
Owner

I will be adding the missing reference that the center frequencies are in ERB. However, the first return value is an array. It is a 2d array as mentioned in the documentation with its shape equal to nfilts * (nfft/2 + 1).
Hopefully, this snippet makes things clearer for you:

import numpy as np
from spafe.utils.converters import erb2hz
from spafe.utils.vis import show_fbanks
from spafe.fbanks.gammatone_fbanks import gammatone_filter_banks

# init var
fs = 8000
nfilts = 7
nfft = 1024
low_freq = 0
high_freq = fs / 2

# compute freqs for xaxis
ghz_freqs = np.linspace(low_freq, high_freq, nfft //2+1)

# init 
scale, label = "constant", ""

# gamma fbanks
gamma_fbanks_mat, gamma_freqs = gammatone_filter_banks(nfilts=nfilts,
	                                               nfft=nfft,
	                                               fs=fs,
	                                               low_freq=low_freq,
	                                               high_freq=high_freq,
	                                               scale=scale,
	                                               order=4)
print(gamma_fbanks_mat.shape, type(gamma_fbanks_mat))
print(gamma_freqs.shape, type(gamma_freqs))

Output:

(7, 513) <class 'numpy.ndarray'>
(7,) <class 'numpy.ndarray'>

@WindDevil
Copy link
Author

Thanks your effort for OpenSourceWorld.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants