Skip to content

Instantly share code, notes, and snippets.

Avatar
Solving environment /

Scott H. Hawley drscotthawley

Solving environment /
View GitHub Profile
@drscotthawley
drscotthawley / tictactoe_policy.py
Last active Aug 17, 2017
My implementation of a temporal difference policy method for playing Tic Tac Toe, after seeing Shlomo Bauer speak at the Brentwood A.I. meetup.
View tictactoe_policy.py
#! /usr/bin/env python3
# Uses temporal difference policy method
# See, e.g., http://www.cs.dartmouth.edu/~lorenzo/teaching/cs134/Archive/Spring2009/final/PengTao/final_report.pdf
# In this code, X plays randomly whereas O 'learns'. (Feel free to change that)
# Thus we expect O to outperform X eventually
# Author: Scott Hawley http://drscotthawley.github.io
# Unlimited License: Feel free to use any or all of this code however you like.
@drscotthawley
drscotthawley / TestRenderMan_DexedVST.ipynb
Created Apr 28, 2018
Slight modification of RenderMan demo, made for Python 3 and MacOS
View TestRenderMan_DexedVST.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@drscotthawley
drscotthawley / apply_sox_effect.py
Last active Apr 29, 2018
Accessing Sox Audio Effects from Python via Pysox
View apply_sox_effect.py
import pysox
import librosa
import numpy as np
def apply_sox_effect(signal, sr, fxstr):
# This writes signal to a .wav file, processes it sox to another file, loads that and returns it.
#
# signal: a numpy list of numbers; the audio signal
# sr: the sample rate in Hz, must be an integer
# fxstr: a semicolon-separated string starting with the effect name followed by parameter values in order
@drscotthawley
drscotthawley / scope_with_trigger.py
Last active May 3, 2018
Realtime waveform display with tunable trigger level
View scope_with_trigger.py
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'Scott H. Hawley'
__copyright__ = 'Scott H. Hawley'
__license__ = "MIT Licence (do what you want, don't blame me)"
import numpy as np
import cv2
import soundcard as sc # https://github.com/bastibe/SoundCard
from scipy.ndimage.interpolation import shift
@drscotthawley
drscotthawley / osc2wek.py
Last active Apr 23, 2019
Sends incoming OSC messages (subject to some filter) to Wekinator
View osc2wek.py
#! /usr/bin/env python3
'''
osc2wek.py
Author: Scott Hawley
This listens for incoming OSC messages and sends them on to Wekinator
Steps to get running (in Terminal):
0. First you need Mercurial "hg". It might be installed by default.
1. Use hg to clone the grail osc code:
@drscotthawley
drscotthawley / proc_fma.py
Last active Aug 22, 2019
FMA dataset conversion script, genre classification, to individual subdirs
View proc_fma.py
#! /usr/env/python3
#
# FMA conversion script, genre classification
# Author: Scott Hawley
# License: Do as you like
#
# For FMA dataset https://github.com/mdeff/fma
# to be used with panotti https://github.com/drscotthawley/panotti
#
# This will create a directory called Samples/
@drscotthawley
drscotthawley / inst_freq.py
Last active Nov 4, 2019
Alternative method for calculating "instantaneous frequency" for use with spectrograms.
View inst_freq.py
#! /usr/bin/env python3
# Test script for Phase 'Unrolling' / Instantaneous frequency
#
# See Jesse Engel's "rainbowgrams" script, https://gist.github.com/jesseengel/e223622e255bd5b8c9130407397a0494
#
# Modifications by Scott H. Hawley, @drscotthawley and Billy Mitchell
# These modified versions seem to be both more accurate (~2000x less reconstruction error)
# and faster (>20%)
#
# note, to really see/hear the difference, change dtypes to np.float16!
@drscotthawley
drscotthawley / faves2bibtex.py
Last active May 20, 2020
Generate BibTex from list of Tweets you (or another user) have favorited ('liked'), tweeted or RT'd
View faves2bibtex.py
#! /usr/bin/env python3
"""
faves2bibtex.py
Author: Scott Hawley
Scrapes URLs contained in tweets you (or another user) favorited ('liked') for DOI & other bibliographic info,
and tries to generate a set of BibTex entries to stdout.
Status messages go to stderr
Sample usage:
@drscotthawley
drscotthawley / newpost.py
Last active Jul 28, 2020
Little script I use to easily start a new Fastpages/Jekyll/Markdown blog entry
View newpost.py
#! /usr/bin/env python
# Little script I use to start a new Markdown blog entry.
# Run from the parent directory above the blog directory,
# or supply a full path to run from anywhere.
#
# Usage: newpost.py <title>
# It automatically figures out what the current date is to
# create a new entry, and supplies a default header with a title
# and a bibliography placement
View FastAICustomModelExample.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.