Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jesseengel
jesseengel / wav2tfrecord.py
Created June 12, 2019 19:25
Wav2TFRecord
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')
@jesseengel
jesseengel / mel_scaling.py
Last active May 3, 2021 09:21
Mel Scaling
# 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 September 5, 2017 17:10
Script to plot "rainbowgrams" from NSynth (https://arxiv.org/abs/1704.01279)
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