This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def istft(stft_matrix, hop_length=None, win_length=None, window='hann', | |
center=True, normalized=False, onesided=True, length=None): | |
"""stft_matrix = (batch, freq, time, complex) | |
All based on librosa | |
- http://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#istft | |
What's missing? | |
- normalize by sum of squared window --> do we need it here? | |
Actually the result is ok by simply dividing y by 2. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn.functional as F | |
EPS = 1e-7 | |
def _enhance_either_hpss(x_padded, out, kernel_size, power, which, offset): | |
"""x_padded: one that median filtering can be directly applied | |
kernel_size = int | |
dim: either 2 (freq-axis) or 3 (time-axis) | |
which: str, either "harm" or "perc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
def STFT(src, n_fft, hop_length=None, window=None, **kwargs): | |
"""A wrapper for torch.stft with some preset parameters. | |
Returned value keeps both real and imageinary parts. | |
For STFT magnitude, see spectrogram | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Net(nn.Module): | |
def __init__(self, src): | |
super(net, self).__init__() | |
self.src = src | |
self.a = a | |
self.conv1 = nn.Conv1d(1, 2, 3, 4,..) | |
def _fwd_1(self, x): | |
x = self.conv1(x) | |
x = x + self.a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cqt_filter_fft = librosa.constantq.__cqt_filter_fft | |
class PseudoCqt(): | |
"""A class to compute pseudo-CQT with Pytorch. | |
Written by Keunwoo Choi | |
API (+implementations) follows librosa (https://librosa.github.io/librosa/generated/librosa.core.pseudo_cqt.html) | |
Usage: | |
src, _ = librosa.load(filename) | |
src_tensor = torch.tensor(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Code converted by Keunwoo from https://ccrma.stanford.edu/~jos/fp/Formant_Filtering_Example.html (JOS) | |
""" | |
import numpy as np | |
import scipy.signal as signal | |
import librosa | |
def gen_speech(F, sig=None, filename='speech'): | |
nsecs = len(F) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
plt.style.use('ggplot') | |
import numpy as np | |
import librosa | |
import keras | |
from keras import backend as K | |
print(keras.__version__) | |
print('Keras backend: ', keras.backend._BACKEND, ' and image dim ordering: ', keras.backend.image_dim_ordering()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras.backend as K | |
# Load the weights | |
# If there are more than 1 BN, you might wanna have a proper layer | |
moving_mean = f['batchnormalization_1_running_mean'] | |
moving_std = f['batchnormalization_1_running_std'] | |
beta = f['batchnormalization_1_beta'] | |
gamma = f['batchnormalization_2_beta'] | |
# BE CAREFUL! Keras 1 stores std |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import keras | |
from keras import backend as K | |
from keras.layers.convolutional import Conv2D, Conv2DTranspose | |
from keras.layers import Input, Dense, Activation | |
from keras.layers import concatenate # functional interface | |
from keras.models import Model | |
from keras.layers.advanced_activations import LeakyReLU | |
N_INPUT = 512 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
links = '''https://ismir2017.smcnus.org/wp-content/uploads/2017/10/126_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/79_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/89_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/119_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/51_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/85_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/164_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/220_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/172_Paper.pdf | |
https://ismir2017.smcnus.org/wp-content/uploads/2017/10/180_Paper.pdf |