Skip to content

Instantly share code, notes, and snippets.

@eldrin
eldrin / my_melspec.py
Last active August 31, 2024 18:18
Quick digging in what makes the mel-spectrum discrepancy between torch audio and librosa
import math
from typing import Callable, Optional
from warnings import warn
import torch
from torch import Tensor
from torchaudio import functional as F
from torchaudio.compliance import kaldi
@eldrin
eldrin / README-Template.md
Created July 29, 2020 08:35 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@eldrin
eldrin / wrmf_test.py
Created October 17, 2019 09:44
Quick sanity check for baseline with given sparse matrix for ranking metric
import os
from functools import partial
import numpy as np
import numba as nb
from scipy import sparse as sp
from implicit.als import AlternatingLeastSquares
from skopt import gp_minimize
from skopt.space import Real, Integer
@eldrin
eldrin / flatten_bibs.py
Created January 4, 2019 23:23
A simple tool to merge two .bib files when one file only contains books and the other file only contains articles
import os
import argparse
import bibtexparser
def read_bibtex(fn):
"""Load bib file
"""
with open(fn) as bibf:
@eldrin
eldrin / process_essentia.py
Last active December 6, 2018 22:36
short script to process `.json` outputs from Essentia's music extractor program
from os.path import join, dirname, basename
import glob
import json
import argparse
from multiprocessing import Pool
import pandas as pd
from flatten_json import flatten_json
from tqdm import tqdm
@eldrin
eldrin / rf_feature_importance.py
Last active September 20, 2018 20:12
visualize feature importance based on Rnadom Forest
from os.path import join, basename, splitext
import argparse
import numpy as np
from sklearn.ensemble import RandomForestClassifier
import matplotlib.pyplot as plt
# setup parser
parser = argparse.ArgumentParser()
parser.add_argument("X", help="filename of the feature file (`.npy`) to visualize")
@eldrin
eldrin / visualize_pca_2d.py
Last active September 20, 2018 17:19
A simple script for visualizing given feature vectors (`.npy` format) in 2-dimensional hyperspace.
from os.path import join, basename, splitext
import argparse
import numpy as np
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
# setup parser
parser = argparse.ArgumentParser()
parser.add_argument("X", help="filename of the feature file (`.npy`) to visualize")
@eldrin
eldrin / easy_feature_extraction_keras2.py
Last active December 10, 2017 12:30
Scripts for extration / test of feature from https://github.com/keunwoochoi/transfer_learning_music (for one newly trained w/ Keras 2.X)
import sys
from keras.models import Model
from keras.layers import GlobalAveragePooling2D as GAP2D
from keras.layers import concatenate as concat
import keras
import kapre
import librosa
import numpy as np