Paddle implemention of part of librosa functions.
Project description
Paddle-Librosa: Paddle implementation of Librosa
This codebase provides Paddle 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, Paddle-Librosa will provide almost identical features to standard paddlelibrosa functions (numerical difference less than 1e-5).
Install
$ git clone https://github.com/AgentMaker/Paddle-Librosa.git
$ pip install Paddle-Librosa/
Examples 1
Extract Log mel spectrogram with Paddle-Librosa.
import paddle
import paddlelibrosa as pl
batch_size = 16
sample_rate = 22050
win_length = 2048
hop_length = 512
n_mels = 128
batch_audio = paddle.uniform((batch_size, sample_rate)) # (batch_size, sample_rate)
# Paddle-Librosa feature extractor the same as librosa.feature.melspectrogram()
feature_extractor = paddle.nn.Sequential(
pl.Spectrogram(
hop_length=hop_length,
win_length=win_length,
), pl.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 Paddle-Librosa.
import paddle
import paddlelibrosa as pl
batch_size = 16
sample_rate = 22050
win_length = 2048
hop_length = 512
n_mels = 128
batch_audio = paddle.empty(batch_size, sample_rate).uniform_(-1, 1) # (batch_size, sample_rate)
# Spectrogram
spectrogram_extractor = pl.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 = pl.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 = pl.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 = pl.ISTFT(n_fft=win_length, hop_length=hop_length)
y = istft_extractor.forward(real, imag, length=batch_audio.shape[-1]) # (batch_size, samples_num)
External links
Other related repos include:
torchlibrosa: https://github.com/qiuqiangkong/torchlibrosa
Contact us
Email : agentmaker@163.com
QQ Group : 1005109853
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file paddlelibrosa-0.0.1.tar.gz.
File metadata
- Download URL: paddlelibrosa-0.0.1.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57ee6e8199e885cf52faf0f7937d81ac1180072a87c91ad987e5c25b612d4849
|
|
| MD5 |
cfea0e9953b710332251e45a1f9c3622
|
|
| BLAKE2b-256 |
cdeaf6d49a75f9f6d06eb6c53866f96688c7e06f0173d75a50ca53d6b077766d
|
File details
Details for the file paddlelibrosa-0.0.1-py3-none-any.whl.
File metadata
- Download URL: paddlelibrosa-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.5.0.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5145ceceef1ec2a67ff4ebe89cb5115a7307c6060d4f40eb7f8b5797ecde6820
|
|
| MD5 |
d8e101dc35dd28da2d62c0cc542ae98b
|
|
| BLAKE2b-256 |
a8dfb8c4294309d8eba35637cdc5cd4f4cd3414362878a8e259168225cae85ae
|