Re-implementation of some librosa function for tensorflow. Reproduction from torchlibrosa.
Project description
tflibrosa
re-implementation of torch librosa for tensorflow. It is usefull if you want to compute Spectrogram on GPU for faster inference instead of using librosa.
Installation
pip install tflibrosa
Example
To do some inference on single sample, you can use python script in examples/ folder or use as follows:
import numpy as np
from tflibrosa import STFT, Spectrogram, LogmelFilterBank
import librosa
import tensorflow as tf
audio = np.random.uniform(0,1 ,(32000 * 5))
print(audio.shape)
sample_rate = 32000
n_fft = 2048
hop_size = 512
window = 'hann'
pad_mode = 'reflect'
mel_bins = 64
ref = 1.0
amin = 1e-10
fmin = 20
fmax = 16000
top_db = 80.0
center = True
dtype=None
spectrogram_extractor = Spectrogram(n_fft=n_fft, hop_length=hop_size,
win_length=n_fft, window=window, center=center, pad_mode=pad_mode,
freeze_parameters=True, dtype="float32")
# Logmel feature extractor
logmel_extractor = LogmelFilterBank(sr=sample_rate, n_fft=n_fft, is_log=True,
n_mels=mel_bins, fmin=fmin, fmax=fmax, ref=ref, amin=amin, top_db=top_db,
freeze_parameters=True, dtype="float32")
spectrogram = spectrogram_extractor(audio[None, :])
mel_spectrogram = logmel_extractor(spectrogram)
print(mel_spectrogram) # (batch size, num_channels, timestamps)
Acknowledgement
- librosa : https://librosa.org/doc/latest/index.html
- torchlibrosa : https://github.com/qiuqiangkong/torchlibrosa
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
tflibrosa-0.0.1.tar.gz
(8.7 kB
view hashes)
Built Distribution
Close
Hashes for tflibrosa-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d4c053c17e02b6ceb6842250b63d62760ab92790c319750c2370c325fcceb99 |
|
MD5 | 85920f97e29b69db111e2c0aaeabbec0 |
|
BLAKE2b-256 | 8d985b7457f5aa41a1f018af01fe22c83feecee606e682f9cd03c61a5646d806 |