@@ -149,13 +149,11 @@ To install the **`audioFlux`** package, Python >=3.6, using the released python
149149Mel spectrogram and Mel-frequency cepstral coefficients
150150
151151``` python
152- # Feature extraction example
153152import numpy as np
154- import matplotlib.pyplot as plt
155-
156153import audioflux as af
154+
155+ import matplotlib.pyplot as plt
157156from audioflux.display import fill_spec
158- from audioflux.type import SpectralFilterBankScaleType
159157
160158# Get a 220Hz's audio file path
161159sample_path = af.utils.sample_path(' 220' )
@@ -164,29 +162,28 @@ sample_path = af.utils.sample_path('220')
164162audio_arr, sr = af.read(sample_path)
165163
166164# Extract mel spectrogram
167- bft_obj = af.BFT(num = 128 , radix2_exp = 12 , samplate = sr,
168- scale_type = SpectralFilterBankScaleType.MEL )
169- spec_arr = bft_obj.bft(audio_arr)
165+ spec_arr, mel_fre_band_arr = af.mel_spectrogram(audio_arr, num = 128 , radix2_exp = 12 , samplate = sr)
170166spec_arr = np.abs(spec_arr)
171167
172- # Create XXCC object and extract mfcc
173- xxcc_obj = af.XXCC(bft_obj.num)
174- xxcc_obj.set_time_length(time_length = spec_arr.shape[1 ])
175- mfcc_arr = xxcc_obj.xxcc(spec_arr)
168+ # Extract mfcc
169+ mfcc_arr, _ = af.mfcc(audio_arr, cc_num = 13 , mel_num = 128 , radix2_exp = 12 , samplate = sr)
176170
171+ # Display
177172audio_len = audio_arr.shape[0 ]
173+ # calculate x/y-coords
174+ x_coords = np.linspace(0 , audio_len / sr, spec_arr.shape[1 ] + 1 )
175+ y_coords = np.insert(mel_fre_band_arr, 0 , 0 )
178176fig, ax = plt.subplots()
179177img = fill_spec(spec_arr, axes = ax,
180- x_coords = bft_obj.x_coords(audio_len),
181- y_coords = bft_obj.y_coords(),
182- x_axis = ' time' , y_axis = ' log' ,
183- title = ' Mel Spectrogram' )
178+ x_coords = x_coords, y_coords = y_coords,
179+ x_axis = ' time' , y_axis = ' log' ,
180+ title = ' Mel Spectrogram' )
184181fig.colorbar(img, ax = ax)
185182
186183fig, ax = plt.subplots()
187184img = fill_spec(mfcc_arr, axes = ax,
188- x_coords = bft_obj. x_coords(audio_len) , x_axis = ' time' ,
189- title = ' MFCC' )
185+ x_coords = x_coords, x_axis = ' time' ,
186+ title = ' MFCC' )
190187fig.colorbar(img, ax = ax)
191188
192189plt.show()
@@ -199,15 +196,14 @@ plt.show()
199196Continuous Wavelet Transform spectrogram and its corresponding synchrosqueezing reassignment spectrogram
200197
201198``` python
202- # Feature extraction example
203199import numpy as np
204- import matplotlib.pyplot as plt
205-
206200import audioflux as af
207- from audioflux.display import fill_spec
208201from audioflux.type import SpectralFilterBankScaleType, WaveletContinueType
209202from audioflux.utils import note_to_hz
210203
204+ import matplotlib.pyplot as plt
205+ from audioflux.display import fill_spec
206+
211207# Get a 220Hz's audio file path
212208sample_path = af.utils.sample_path(' 220' )
213209
@@ -230,15 +226,15 @@ synsq_arr = synsq_obj.synsq(cwt_spec_arr,
230226 fre_arr = cwt_obj.get_fre_band_arr())
231227
232228# Show CWT
233- fig, ax = plt.subplots(figsize = (7 ,4 ))
229+ fig, ax = plt.subplots(figsize = (7 , 4 ))
234230img = fill_spec(np.abs(cwt_spec_arr), axes = ax,
235231 x_coords = cwt_obj.x_coords(),
236232 y_coords = cwt_obj.y_coords(),
237233 x_axis = ' time' , y_axis = ' log' ,
238234 title = ' CWT' )
239235fig.colorbar(img, ax = ax)
240236# Show Synsq
241- fig, ax = plt.subplots(figsize = (7 ,4 ))
237+ fig, ax = plt.subplots(figsize = (7 , 4 ))
242238img = fill_spec(np.abs(synsq_arr), axes = ax,
243239 x_coords = cwt_obj.x_coords(),
244240 y_coords = cwt_obj.y_coords(),
@@ -276,11 +272,11 @@ Using PyPI:
276272$ pip install audioflux
277273```
278274
279- <!-- Using Anaconda:
275+ Using Anaconda:
280276
281277```
282- $ conda install -c conda-forge audioflux
283- ```-->
278+ $ conda install -c tanky25 -c conda-forge audioflux
279+ ```
284280
285281
286282<!-- Read installation instructions:
@@ -303,7 +299,7 @@ Enter the **`audioFlux`** project **`scripts`** directory and switch to the curr
303299$ ./build_iOS.sh
304300```
305301
306- Build and compile successfully, the project build compilation results are in the ** ` build ` ** folder
302+ Build and compile successfully, the project build compilation results are in the ** ` build ` ** folder
307303
308304### Android build
309305
@@ -324,7 +320,7 @@ Enter the **`audioFlux`** project **`scripts`** directory and switch to the curr
324320$ ./build_android.sh
325321```
326322
327- Build and compile successfully, the project build compilation results are in the ** ` build ` ** folder
323+ Build and compile successfully, the project build compilation results are in the ** ` build ` ** folder
328324
329325
330326### Building from source
0 commit comments