Skip to content

Instantly share code, notes, and snippets.

View markostam's full-sized avatar
🌵
🌵

Marko Stamenovic markostam

🌵
🌵
View GitHub Profile
@markostam
markostam / audio_tools.py
Created December 14, 2018 04:23 — forked from kastnerkyle/audio_tools.py
Audio tools for numpy/python. Constant work in progress.
raise ValueError("DEPRECATED/FROZEN - see https://github.com/kastnerkyle/tools for the latest")
# License: BSD 3-clause
# Authors: Kyle Kastner
# Harvest, Cheaptrick, D4C, WORLD routines based on MATLAB code from M. Morise
# http://ml.cs.yamanashi.ac.jp/world/english/
# MGC code based on r9y9 (Ryuichi Yamamoto) MelGeneralizedCepstrums.jl
# Pieces also adapted from SPTK
from __future__ import division
import numpy as np
@markostam
markostam / phase_vocoder.py
Last active February 28, 2022 10:20
Phase vocoder in pure tensorflow
def phase_vocoder(D, hop_len=None, rate=0.8):
"""Phase vocoder. Given an STFT matrix D, speed up by a factor of `rate`.
Based on implementation provided by:
https://librosa.github.io/librosa/_modules/librosa/core/spectrum.html#phase_vocoder
:param D: tf.complex64([num_frames, num_bins]): the STFT tensor
:param hop_len: float: the hop length param of the STFT
:param rate: float > 0: the speed-up factor
:return: D_stretched: tf.complex64([num_frames, num_bins]): the stretched STFT tensor
"""
import numpy as np
import sys
def read_data(file):
with open(file) as f:
raw = map(lambda x: x.split(),f.readlines())
input = list(map(lambda sides: list(map(lambda side: int(side),sides)),raw))
return input
def check_tri(input, count = 0):
from bitarray import bitarray
class BloomFilter:
def __init__(self):
# use bitarray instead of list to save space
self.ba = bitarray(10**8)
def _hash_fxn1(self, x):
if type(x) == str:
class QuickSort {
// quicksort function in scala
def sort(a:Array[Int]) : Array[Int] = {
if (a.length < 2) a
else {
val pivot = a(a.length/2)
sort(a.filter(_ < pivot)) ++ a.filter(_ == pivot) ++ sort(a.filter(_ > pivot))
}
}
}
import random
import timeit
# quicksort python
def quicksort(a):
if len(a) < 2:
return a
else:
pivot = a[int(len(a)/2)]
@markostam
markostam / ticTacToe.py
Last active June 3, 2016 05:26
python tic tac toe game. marko s for the recurse center coding challenge.
'''
tic tac toe game in python
marko stamenovic
june 1 2016
recurse center coding challenge
'''
#initialize board
xsos = [' ',' ',' ',' ',' ',' ',' ',' ',' ']
#list of possible moves