From ada306aa9ed84013f7bf203ec4e1d2063cd5bb14 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Fri, 5 May 2023 09:19:40 +0000 Subject: automatic import of python-torchlibrosa --- python-torchlibrosa.spec | 359 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 python-torchlibrosa.spec (limited to 'python-torchlibrosa.spec') diff --git a/python-torchlibrosa.spec b/python-torchlibrosa.spec new file mode 100644 index 0000000..998f26f --- /dev/null +++ b/python-torchlibrosa.spec @@ -0,0 +1,359 @@ +%global _empty_manifest_terminate_build 0 +Name: python-torchlibrosa +Version: 0.1.0 +Release: 1 +Summary: PyTorch implemention of part of librosa functions. +License: MIT License +URL: https://github.com/qiuqiangkong/torchlibrosa +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/a4/67/e4c79da3f15777b9bc2b655d47dac553fc31e40360500fef5e66d6877ce8/torchlibrosa-0.1.0.tar.gz +BuildArch: noarch + +Requires: python3-numpy +Requires: python3-librosa + +%description +# TorchLibrosa: PyTorch implementation of Librosa + +This codebase provides PyTorch implementation of some librosa functions. If users previously used for training cpu-extracted features from librosa, but want to add GPU acceleration during training and evaluation, TorchLibrosa will provide almost identical features to standard torchlibrosa functions (numerical difference less than 1e-5). + +## Install +```bash +$ pip install torchlibrosa +``` + +## Examples 1 + +Extract Log mel spectrogram with TorchLibrosa. + +```python +import torch +import torchlibrosa as tl + +batch_size = 16 +sample_rate = 22050 +win_length = 2048 +hop_length = 512 +n_mels = 128 + +batch_audio = torch.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate) + +# TorchLibrosa feature extractor the same as librosa.feature.melspectrogram() +feature_extractor = torch.nn.Sequential( + tl.Spectrogram( + hop_length=hop_length, + win_length=win_length, + ), tl.LogmelFilterBank( + sr=sample_rate, + n_mels=n_mels, + is_log=False, # Default is true + )) +batch_feature = feature_extractor(batch_audio) # (batch_size, 1, time_steps, mel_bins) +``` + +## Examples 2 + +Extracting spectrogram, then log mel spectrogram, STFT and ISTFT with TorchLibrosa. + +```python +import torch +import torchlibrosa as tl + +batch_size = 16 +sample_rate = 22050 +win_length = 2048 +hop_length = 512 +n_mels = 128 + +batch_audio = torch.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate) + +# Spectrogram +spectrogram_extractor = tl.Spectrogram(n_fft=win_length, hop_length=hop_length) +sp = spectrogram_extractor.forward(batch_audio) # (batch_size, 1, time_steps, freq_bins) + +# Log mel spectrogram +logmel_extractor = tl.LogmelFilterBank(sr=sample_rate, n_fft=win_length, n_mels=n_mels) +logmel = logmel_extractor.forward(sp) # (batch_size, 1, time_steps, mel_bins) + +# STFT +stft_extractor = tl.STFT(n_fft=win_length, hop_length=hop_length) +(real, imag) = stft_extractor.forward(batch_audio) +# real: (batch_size, 1, time_steps, freq_bins), imag: (batch_size, 1, time_steps, freq_bins) # + +# ISTFT +istft_extractor = tl.ISTFT(n_fft=win_length, hop_length=hop_length) +y = istft_extractor.forward(real, imag, length=batch_audio.shape[-1]) # (batch_size, samples_num) +``` + +## Example 3 + +Check the compability of TorchLibrosa to Librosa. The numerical difference should be less than 1e-5. + +```python +python3 torchlibrosa/stft.py --device='cuda' # --device='cpu' | 'cuda' +``` + +## Contact +Qiuqiang Kong, qiuqiangkong@gmail.com + +## Cite +[1] Qiuqiang Kong, Yin Cao, Turab Iqbal, Yuxuan Wang, Wenwu Wang, and Mark D. Plumbley. "PANNs: Large-scale pretrained audio neural networks for audio pattern recognition." IEEE/ACM Transactions on Audio, Speech, and Language Processing 28 (2020): 2880-2894. + +## External links +Other related repos include: + +torchaudio: https://github.com/pytorch/audio + +Asteroid-filterbanks: https://github.com/asteroid-team/asteroid-filterbanks + +Kapre: https://github.com/keunwoochoi/kapre + + + +%package -n python3-torchlibrosa +Summary: PyTorch implemention of part of librosa functions. +Provides: python-torchlibrosa +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-torchlibrosa +# TorchLibrosa: PyTorch implementation of Librosa + +This codebase provides PyTorch implementation of some librosa functions. If users previously used for training cpu-extracted features from librosa, but want to add GPU acceleration during training and evaluation, TorchLibrosa will provide almost identical features to standard torchlibrosa functions (numerical difference less than 1e-5). + +## Install +```bash +$ pip install torchlibrosa +``` + +## Examples 1 + +Extract Log mel spectrogram with TorchLibrosa. + +```python +import torch +import torchlibrosa as tl + +batch_size = 16 +sample_rate = 22050 +win_length = 2048 +hop_length = 512 +n_mels = 128 + +batch_audio = torch.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate) + +# TorchLibrosa feature extractor the same as librosa.feature.melspectrogram() +feature_extractor = torch.nn.Sequential( + tl.Spectrogram( + hop_length=hop_length, + win_length=win_length, + ), tl.LogmelFilterBank( + sr=sample_rate, + n_mels=n_mels, + is_log=False, # Default is true + )) +batch_feature = feature_extractor(batch_audio) # (batch_size, 1, time_steps, mel_bins) +``` + +## Examples 2 + +Extracting spectrogram, then log mel spectrogram, STFT and ISTFT with TorchLibrosa. + +```python +import torch +import torchlibrosa as tl + +batch_size = 16 +sample_rate = 22050 +win_length = 2048 +hop_length = 512 +n_mels = 128 + +batch_audio = torch.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate) + +# Spectrogram +spectrogram_extractor = tl.Spectrogram(n_fft=win_length, hop_length=hop_length) +sp = spectrogram_extractor.forward(batch_audio) # (batch_size, 1, time_steps, freq_bins) + +# Log mel spectrogram +logmel_extractor = tl.LogmelFilterBank(sr=sample_rate, n_fft=win_length, n_mels=n_mels) +logmel = logmel_extractor.forward(sp) # (batch_size, 1, time_steps, mel_bins) + +# STFT +stft_extractor = tl.STFT(n_fft=win_length, hop_length=hop_length) +(real, imag) = stft_extractor.forward(batch_audio) +# real: (batch_size, 1, time_steps, freq_bins), imag: (batch_size, 1, time_steps, freq_bins) # + +# ISTFT +istft_extractor = tl.ISTFT(n_fft=win_length, hop_length=hop_length) +y = istft_extractor.forward(real, imag, length=batch_audio.shape[-1]) # (batch_size, samples_num) +``` + +## Example 3 + +Check the compability of TorchLibrosa to Librosa. The numerical difference should be less than 1e-5. + +```python +python3 torchlibrosa/stft.py --device='cuda' # --device='cpu' | 'cuda' +``` + +## Contact +Qiuqiang Kong, qiuqiangkong@gmail.com + +## Cite +[1] Qiuqiang Kong, Yin Cao, Turab Iqbal, Yuxuan Wang, Wenwu Wang, and Mark D. Plumbley. "PANNs: Large-scale pretrained audio neural networks for audio pattern recognition." IEEE/ACM Transactions on Audio, Speech, and Language Processing 28 (2020): 2880-2894. + +## External links +Other related repos include: + +torchaudio: https://github.com/pytorch/audio + +Asteroid-filterbanks: https://github.com/asteroid-team/asteroid-filterbanks + +Kapre: https://github.com/keunwoochoi/kapre + + + +%package help +Summary: Development documents and examples for torchlibrosa +Provides: python3-torchlibrosa-doc +%description help +# TorchLibrosa: PyTorch implementation of Librosa + +This codebase provides PyTorch implementation of some librosa functions. If users previously used for training cpu-extracted features from librosa, but want to add GPU acceleration during training and evaluation, TorchLibrosa will provide almost identical features to standard torchlibrosa functions (numerical difference less than 1e-5). + +## Install +```bash +$ pip install torchlibrosa +``` + +## Examples 1 + +Extract Log mel spectrogram with TorchLibrosa. + +```python +import torch +import torchlibrosa as tl + +batch_size = 16 +sample_rate = 22050 +win_length = 2048 +hop_length = 512 +n_mels = 128 + +batch_audio = torch.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate) + +# TorchLibrosa feature extractor the same as librosa.feature.melspectrogram() +feature_extractor = torch.nn.Sequential( + tl.Spectrogram( + hop_length=hop_length, + win_length=win_length, + ), tl.LogmelFilterBank( + sr=sample_rate, + n_mels=n_mels, + is_log=False, # Default is true + )) +batch_feature = feature_extractor(batch_audio) # (batch_size, 1, time_steps, mel_bins) +``` + +## Examples 2 + +Extracting spectrogram, then log mel spectrogram, STFT and ISTFT with TorchLibrosa. + +```python +import torch +import torchlibrosa as tl + +batch_size = 16 +sample_rate = 22050 +win_length = 2048 +hop_length = 512 +n_mels = 128 + +batch_audio = torch.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate) + +# Spectrogram +spectrogram_extractor = tl.Spectrogram(n_fft=win_length, hop_length=hop_length) +sp = spectrogram_extractor.forward(batch_audio) # (batch_size, 1, time_steps, freq_bins) + +# Log mel spectrogram +logmel_extractor = tl.LogmelFilterBank(sr=sample_rate, n_fft=win_length, n_mels=n_mels) +logmel = logmel_extractor.forward(sp) # (batch_size, 1, time_steps, mel_bins) + +# STFT +stft_extractor = tl.STFT(n_fft=win_length, hop_length=hop_length) +(real, imag) = stft_extractor.forward(batch_audio) +# real: (batch_size, 1, time_steps, freq_bins), imag: (batch_size, 1, time_steps, freq_bins) # + +# ISTFT +istft_extractor = tl.ISTFT(n_fft=win_length, hop_length=hop_length) +y = istft_extractor.forward(real, imag, length=batch_audio.shape[-1]) # (batch_size, samples_num) +``` + +## Example 3 + +Check the compability of TorchLibrosa to Librosa. The numerical difference should be less than 1e-5. + +```python +python3 torchlibrosa/stft.py --device='cuda' # --device='cpu' | 'cuda' +``` + +## Contact +Qiuqiang Kong, qiuqiangkong@gmail.com + +## Cite +[1] Qiuqiang Kong, Yin Cao, Turab Iqbal, Yuxuan Wang, Wenwu Wang, and Mark D. Plumbley. "PANNs: Large-scale pretrained audio neural networks for audio pattern recognition." IEEE/ACM Transactions on Audio, Speech, and Language Processing 28 (2020): 2880-2894. + +## External links +Other related repos include: + +torchaudio: https://github.com/pytorch/audio + +Asteroid-filterbanks: https://github.com/asteroid-team/asteroid-filterbanks + +Kapre: https://github.com/keunwoochoi/kapre + + + +%prep +%autosetup -n torchlibrosa-0.1.0 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-torchlibrosa -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot - 0.1.0-1 +- Package Spec generated -- cgit v1.2.3