libAudioFlux / audioFlux

A library for audio and music analysis, feature extraction.
https://audioflux.top
MIT License
2.1k stars 102 forks source link

Speed is slow, am I miss something? #18

Open fire717 opened 1 year ago

fire717 commented 1 year ago

install: pip install audioflux

os: ubuntu18 python3.8

fire717 commented 1 year ago

tried unintsll audioflux and reinstall through conda, met same error

liufeigit commented 1 year ago

Thanks for the feedback, the online pip is compiled based on ubuntu20, and we will fix this bug for ubuntu 18 later.

Now, you can try to install from source: https://github.com/libAudioFlux/audioFlux/blob/master/docs/installing.md#building-from-source

fire717 commented 1 year ago

Thanks for the feedback, the online pip is compiled based on ubuntu20, and we will fix this bug for ubuntu 18 later.

Now, you can try to install from source: https://github.com/libAudioFlux/audioFlux/blob/master/docs/installing.md#building-from-source

Thx, and I can use it by installing from source now. But I found the speed is slow, am I miss something?

My test code:

sig, sr = librosa.load(sample_path,sr=None)
mel = librosa.feature.melspectrogram(y=audio, sr=sample_rate)

sig, sr =torchaudio.load(sample_path)
mel = torchaudio.transforms.MelSpectrogram(sr, n_fft=2048, 
        hop_length=512, 
        n_mels=128,
        pad_mode='constant')
mel = torchaudio.transforms.AmplitudeToDB(top_db=None)(mel)

sig, sr = af.read(sample_path)
mel, mel_fre_band_arr = af.mel_spectrogram(sig, num=128, samplate=sr)#radix2_exp=12, 
mel = np.abs(mel)

And my result:

load time cost:

librosa:             0.017s      len(sig)=1459513   sr=32000
torchaudio:      0.021s      len(sig)=1459513   sr=32000
audioflux:         0.017s      len(sig)=1459513   sr=32000

to mel time cost:

librosa:             0.041s       output shape=[128,2851]
torchaudio:      0.011s       output shape=[128,2851]
audioflux:         0.066s       output shape=[128,1422]
wtq2255 commented 1 year ago

@fire717 Thanks for your test feedback, it revealed some performance issues with our project. This is mainly reflected in the feature extraction of long audio, for which we released latest version. You can check out this benchmark. At the same time, you can also check the test script to see if there are any problems.

liufeigit commented 1 year ago

https://github.com/libAudioFlux/audioFlux/tree/master/benchmark

Here are the new detailed performance benchmark data and test scripts. Thanks feedback.