Skip to content

Instantly share code, notes, and snippets.

@RicherMans
Created December 16, 2020 05:34
Show Gist options
  • Save RicherMans/5b5784db8a5aee6d23e0bc22e6146d57 to your computer and use it in GitHub Desktop.
Save RicherMans/5b5784db8a5aee6d23e0bc22e6146d57 to your computer and use it in GitHub Desktop.
Torchlibrosa default to Librosa LMS
import librosa
import numpy as np
import torchlibrosa as tl
import torch
import soundfile as sf
y, sr = sf.read('.Y0Am7X758-Ek_30.000_40.000.wav')
# Channels normalization (if neceesary
y = y.mean(-1)
spec_extractor = tl.stft.Spectrogram(n_fft=1024, hop_length=400, win_length=160)
lms_extractor = tl.stft.LogmelFilterBank(sr=sr, n_fft=1024, n_mels=64, is_log=False, fmin=0.0, fmax=sr//2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment