Basically, this takes a MIDI input file (I just googled and grabbed one of Maroon 5's "Animal" – I know, I know) and generates a WAV file.
NOTE: This is the slowest midi rendering program I have ever seen!
Dependencies:
- Pydub (pydub.com)
import cv2 | |
cap = cv2.VideoCapture(0) | |
while True: | |
_, frame = cap.read() | |
hsvMin = (20,120,120) | |
hsvMax = (49,255,255) | |
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV) |
''' | |
A hack based on this http://mikepultz.com/2011/03/accessing-google-speech-api-chrome-11/. While with smaller voice samples google speech to text works really good, as length increases quality decreases. So here using audiolab and numPy we are breaking audio sample, in smaller chunks, and removing blank/empty spaces from audio signal and then pushing them to google for processing. | |
It takes wav file format as input but can be changed to other formats too. | |
''' | |
from scikits.audiolab import wavread, play, flacwrite | |
from numpy import average, array, hstack | |
import os | |
import sys |
#!/usr/bin/env bash | |
SOUNDFONT=/Users/kroger/Dropbox/Sfonts/BOPLMEVF16.sf2 | |
TMPDIR=/tmp | |
if [[ ! -f $SOUNDFONT ]] | |
then | |
echo "Couldn't find the soundfont: $SOUNDFONT" | |
exit 1 |
# When setuptools need to be upgraded | |
(venv) $ python -m pip install --upgrade --force setuptools | |
(venv) $ python -m pip install --upgrade --force pip |
Basically, this takes a MIDI input file (I just googled and grabbed one of Maroon 5's "Animal" – I know, I know) and generates a WAV file.
NOTE: This is the slowest midi rendering program I have ever seen!
Dependencies:
A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.
As it turns out, there are several open-source tools that allow for conversion between file types. Pandoc is one of them, and it's powerful. In fact, pandoc's website says "If you need to convert files from one markup format into another, pandoc is your swiss-army knife." But, although pandoc can convert from markdown into .docx, it doesn't work in the other direction.
#!/usr/local/bin/python | |
# Filename: jmkfigure.py | |
# from matplotlib import rc | |
from pylab import * | |
def djmkfigure(width,vext): | |
""" | |
djmkfigure(width,vext): | |
width is column widths, and vext is fractional 10 page height. |
"""quick way to create a data frame to try things out""" | |
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd']) | |
df['A'] """ will bring out a col """ df.ix[0] """will bring out a row, #0 in this case""" | |
"""Given a dataframe df to filter by a series s:""" | |
df[df['col_name'].isin(s)] | |
"""to do the same filter on the index instead of arbitrary column""" | |
df.ix[s] |
Oddly enough ggplot2 has no support for a stacked and grouped (position="dodge") bar plot. The seaborn python package, although excellent, also does not provide an alternative. However, I knew it was surely possible to make such a plot in regular matplotlib. Matplotlib, although sometimes clunky, gives you enough flexibility to precisely place plotting elements which is needed for a stacked
and grouped
bar plot.
Below is a working example of making a stacked and grouped bar plot.
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" NeoBundle " | |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" install and init NeoBundle | |
if has('vim_starting') | |
set nocompatible | |
set runtimepath+=~/.vim/bundle/neobundle.vim/ | |
endif |