This file contains hidden or 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
# Keunwoo Choi | |
# This example crawl snoring sound by searching keyword 'snore'. | |
from __future__ import print_function | |
import freesound # $ git clone https://github.com/MTG/freesound-python | |
import os | |
import sys | |
api_key = 'YOUR_API_KEY' | |
folder = 'data_freesound/' # folder to save |
This file contains hidden or 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 gen(): | |
print('generator initiated') | |
idx = 0 | |
while True: | |
yield x_train[:32], y_train[:32] | |
print('generator yielded a batch %d' % idx) | |
idx += 1 | |
tr_gen = gen() | |
model.fit_generator(generator=tr_gen, steps_per_epoch=20, max_queue_size=10) |
This file contains hidden or 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 time | |
def gen(): | |
print('generator initiated') | |
idx = 0 | |
while True: | |
yield x_train[:32], y_train[:32] | |
print('generator yielded a batch %d' % idx) | |
idx += 1 | |
time.sleep(3) |
This file contains hidden or 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 gen(): | |
print('generator initiated') | |
idx = 0 | |
while True: | |
yield x_train[:32], y_train[:32] | |
print('generator yielded a batch %d' % idx) | |
idx += 1 | |
tr_gen = gen() | |
model.fit_generator(generator=tr_gen, steps_per_epoch=20, max_queue_size=10, |
This file contains hidden or 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 threading | |
class threadsafe_iter: | |
"""Takes an iterator/generator and makes it thread-safe by | |
serializing call to the `next` method of given iterator/generator. | |
""" | |
def __init__(self, it): | |
self.it = it | |
self.lock = threading.Lock() |
This file contains hidden or 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 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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) |