Skip to content

Instantly share code, notes, and snippets.

View fokx's full-sized avatar

fokx

View GitHub Profile
@fokx
fokx / wav2tfrecord.py
Created July 3, 2020 12:34 — forked from jesseengel/wav2tfrecord.py
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')
@fokx
fokx / mel_scaling.py
Created July 3, 2020 12:34 — forked from jesseengel/mel_scaling.py
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)
@fokx
fokx / rainbowgram.py
Created July 3, 2020 12:26 — forked from jesseengel/rainbowgram.py
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