Skip to content

Instantly share code, notes, and snippets.

View wav2tfrecord.py
from cStringIO import StringIO
import os
import numpy as np
import scipy.io.wavfile
import tensorflow as tf
output_path = os.path.expanduser('~/Desktop/test.tfrecord')
sample_path = os.path.expanduser('~/Desktop/test.wav')
View mel_scaling.py
# mel spectrum constants.
_MEL_BREAK_FREQUENCY_HERTZ = 700.0
_MEL_HIGH_FREQUENCY_Q = 1127.0
def mel_to_hertz(mel_values):
"""Converts frequencies in `mel_values` from the mel scale to linear scale."""
return _MEL_BREAK_FREQUENCY_HERTZ * (
np.exp(np.array(mel_values) / _MEL_HIGH_FREQUENCY_Q) - 1.0)
@jesseengel
jesseengel / rainbowgram.py
Created Sep 5, 2017
Script to plot "rainbowgrams" from NSynth (https://arxiv.org/abs/1704.01279)
View rainbowgram.py
import os
import librosa
import matplotlib
import matplotlib.pyplot as plt
matplotlib.rcParams['svg.fonttype'] = 'none'
import numpy as np
from scipy.io.wavfile import read as readwav
# Constants