Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
miles to go before i sleep

Mohit Cheppudira 0xfe

💭
miles to go before i sleep
View GitHub Profile
View gist:69132304ee5dd4088f0ef03a7c4bc636
### Keybase proof
I hereby claim:
* I am 0xfe on github.
* I am qubit (https://keybase.io/qubit) on keybase.
* I have a public key ASD0Ru2w_nyBeID3S3RPL2faUhfcmqYupCNqychcsEb2dAo
To claim this, I am signing this object:
View gist:df956eb0a3ece0c56180c27823c33884
Verifying my Blockstack ID is secured with the address 15Gn9qP2zjEJcKKxmtfCq232HP9H2RAohK https://explorer.blockstack.org/address/15Gn9qP2zjEJcKKxmtfCq232HP9H2RAohK
@0xfe
0xfe / quid.css
Created Dec 29, 2018
Quid Client CSS
View quid.css
button.quid-pay-button {
background: rgba(255, 255, 255, 0.1) !important;
border: none !important;
border-bottom: 2px #00625d solid !important;
border-radius: 3px !important;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
font-size: 12px !important;
margin: 0 !important;
outline: 0 !important;
padding: 8px !important;
@0xfe
0xfe / deep-pitches-samplegen.py
Last active Feb 23, 2020
Generate audio samples for training
View deep-pitches-samplegen.py
#!/usr/bin/env python3
import os
import re
import tempfile
import math
import random
import numpy as np
from midiutil.MidiFile import MIDIFile
from midi import Note, GM_PATCHES
@0xfe
0xfe / gm_patches.py
Last active Feb 22, 2020
Selected General MIDI patches
View gm_patches.py
GM_PATCHES = [
0, # Acoustic Grand Piano
3, # Honky-tonk Piano
6, # Harpsichord
11, # Vibraphone
16, # Drawbar Organ
19, # Church Organ
22, # Harmonica
24, # Acoustic Guitar (nylon)
26, # Electric Guitar (jazz)
View midi_note_helper.py
class Note:
values = {
"c": 0,
"d": 2,
"e": 4,
"f": 5,
"g": 7,
"a": 9,
"b": 11
}
@0xfe
0xfe / spectrogram.py
Created Feb 22, 2020
Python Spectrogram
View spectrogram.py
DefaultConfig = Config(
rows=513,
cols = 90,
s_nperseg = 256,
s_nfft = 1024,
s_noverlap = 200,
resample = 16000)
def spectrogram(file, config=DefaultConfig):
fs, data = wavfile.read(file)
@0xfe
0xfe / deep-pitches-model.py
Created Feb 23, 2020
Deep Convnet Model for Pitch Detection
View deep-pitches-model.py
self.model = tf.keras.models.Sequential([
# Add features/channels dim for Conv2D layer
layers.Reshape((self.s_rows, self.s_cols, 1), input_shape=(self.s_rows, self.s_cols)),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Conv2D(64, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(pool_size=(2,2)),
tf.keras.layers.Conv2D(128, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(pool_size=(2,2)),
tf.keras.layers.Conv2D(128, (3,3), activation='relu'),
tf.keras.layers.MaxPooling2D(pool_size=(2,2)),
@0xfe
0xfe / deep-pitches-build-training-data.py
Created Feb 23, 2020
Build Training Data for Deep Pitches
View deep-pitches-build-training-data.py
for octave in range(2, 8):
random.shuffle(GM_PATCHES)
for patch in range(0, 15):
program = GM_PATCHES[patch]
for key in Note.names:
sample = Sample("samples/note-%s%s-P%s" % (key, octave, program),
program=program, key=key, octave=octave)
sample.make_wav()
for pitch_shift_hz in np.concatenate((np.array([0]), np.random.randint(10, 80, 5))):
sample.transform_wav(
@0xfe
0xfe / deep-pitches-start-training.py
Created Feb 23, 2020
Start Training the Deep Pitches Model
View deep-pitches-start-training.py
self.model.fit(training_xs, training_ys, epochs=150, batch_size=32,
callbacks=[tf.keras.callbacks.EarlyStopping(monitor='val_mse', patience=25)],
validation_data=(testing_xs, testing_ys))