Skip to content

Instantly share code, notes, and snippets.

@pseeth
pseeth / demo.py
Last active October 16, 2020 22:51
ArgBind demo
import argbind
from typing import List
@argbind.bind()
def train(epochs : int = 50):
"""Run training.
Parameters
----------
epochs : int, optional
@pseeth
pseeth / bind_func_to_argparse.py
Last active July 27, 2020 22:02
A simple way to access function keyword arguments from the command line. Handy for command line configuration of experiments.
# Example of binding function keyword arguments to an
# ArgumentParser, then using scopes to initialize function
# with different arguments.
#
# Example output:
# ❯ python example.py --autoclip.percentile=100 --train/autoclip.percentile=1 --val/autoclip.percentile=5
# Before scoping
# ARGS={}
# Called autoclip with percentile=10.0
#
#!/usr/bin/env python
"""
Script to wait for an open GPU, then to run the job. Use with
`tsp` (task-spooler) for a common workflow, by queuing a job
that looks for a GPU and then runs the actual job.
Make this executable: chmod +x allocate.py
This stacks jobs on a single GPU if memory is available and the
@pseeth
pseeth / scaper_tutorial.py
Last active March 1, 2020 20:13
Self-contained tutorial for Scaper w/ downloading
# to install requirements
# conda install -c conda-forge sox ffmpeg
# OR
# brew install sox
# brew install ffmpeg
# OR
# sudo apt-get install sox
# sudo apt-get install ffmpeg
# THEN
# pip install scaper
@pseeth
pseeth / make_coherent_mix.py
Last active April 6, 2019 02:43
Making coherent music mixtures with Scaper
import sys
sys.path.insert(0, '.')
from multiprocessing import cpu_count
import os
from utils import parallel_process
from scaper import Scaper, generate_from_jams
import librosa
import numpy as np
from tqdm import tqdm
@pseeth
pseeth / coherent_music_generation_with_scaper.py
Last active August 2, 2018 21:15
Generating coherent music with Scaper
import scaper
import os
import sox
import numpy as np
import logging
import warnings
import random
import jams
import librosa
import itertools
"""Helper functions for working with audio files in NumPy."""
import numpy as np
import contextlib
def pcm2float(sig, dtype='float64'):
"""Convert PCM signal to floating point with a range from -1 to 1.
Use dtype='float32' for single precision.
"""Helper functions for working with audio files in NumPy."""
import numpy as np
import contextlib
def pcm2float(sig, dtype='float64'):
"""Convert PCM signal to floating point with a range from -1 to 1.
Use dtype='float32' for single precision.
reverb_words = keys(wordDict['reverb'])
word_parameters = {}
function get_parameters() {return {'g': rev.g, 'd': rev.d, 'm': rev.m, 'f': rev.f, 'E': rev.E, 'wetdry': rev.wetdry}}
function save_word(index) {console.log(reverb_words[index]); changetoword(reverb_words[index], 'reverb', -1); word_parameters[reverb_words[index]] = get_parameters();}
current_index = 0;
function increment_word() {save_word(current_index); current_index++};
interval_thing = setInterval(increment_word, 1000);
eq_words = keys(wordDict['eq'])
function save_word_eq(index) {console.log(eq_words[index]); changetoword(eq_words[index], 'eq', -1);}