Skip to content

Instantly share code, notes, and snippets.

View timsainb's full-sized avatar

Tim Sainburg timsainb

View GitHub Profile
@kastnerkyle
kastnerkyle / make_audiobook.py
Created April 26, 2020 20:55 — forked from madebyollin/make_audiobook.py
Converts an epub or text file to audiobook via Google Cloud TTS
#!/usr/bin/env python3
"""
To use:
1. install/set-up the google cloud api and dependencies listed on https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/texttospeech/cloud-client
2. install pandoc and pypandoc, also tqdm
3. create and download a service_account.json ("Service account key") from https://console.cloud.google.com/apis/credentials
4. run GOOGLE_APPLICATION_CREDENTIALS=service_account.json python make_audiobook.py book_name.epub
"""
import re
import sys
@RaphaelMeudec
RaphaelMeudec / kernel_visualization.py
Last active May 14, 2020 18:44
Visualize convolutional kernels with Tensorflow 2.0
import numpy as np
import tensorflow as tf
# Layer name to inspect
layer_name = 'block3_conv1'
epochs = 100
step_size = 1.
filter_index = 0
@kylemcdonald
kylemcdonald / dtw_mse.py
Last active April 28, 2021 16:28
DTW MSE numba function for use with UMAP.
# based on https://github.com/kylerbrown/ezdtw
# with modifications to be fully njit-able
import numpy as np
from numba import njit
@njit
def sqeuclidean(a, b):
return np.sum((a - b)**2)
@aaronstevenwhite
aaronstevenwhite / unsupervisedpcfg.py
Last active March 26, 2022 15:42
Unsupervised probabilistic context free grammar induction with expectation maximization
import numpy as np
import pandas as pd
from random import shuffle, choice
from scipy.stats import dirichlet
from scipy.misc import logsumexp
from nltk.tree import Tree
class UnsupervisedPCFG(object):
'''unsupervised pcfg induction with EM
@kastnerkyle
kastnerkyle / Signal reconstruction from spectrograms.ipynb
Created May 31, 2018 18:17 — forked from carlthome/Signal reconstruction from spectrograms.ipynb
Try to recover audio from filtered magnitudes when phase information has been lost.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danijar
danijar / blog_tensorflow_variational_auto_encoder.py
Last active February 22, 2023 09:02
TensorFlow Variational Auto-Encoder
# Full example for my blog post at:
# https://danijar.com/building-variational-auto-encoders-in-tensorflow/
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
tfd = tf.contrib.distributions
@cbaziotis
cbaziotis / Attention.py
Last active March 28, 2023 11:50
Keras Layer that implements an Attention mechanism for temporal data. Supports Masking. Follows the work of Raffel et al. [https://arxiv.org/abs/1512.08756]
from keras import backend as K, initializers, regularizers, constraints
from keras.engine.topology import Layer
def dot_product(x, kernel):
"""
Wrapper for dot product operation, in order to be compatible with both
Theano and Tensorflow
Args:
@PolarNick239
PolarNick239 / rgb_to_hsv_np.py
Last active January 14, 2023 10:48
numpy RGB to HSV
#
# Copyright (c) 2016, Nikolay Polyarnyi
# All rights reserved.
#
import numpy as np
def rgb_to_hsv(rgb):
"""
@kastnerkyle
kastnerkyle / audio_tools.py
Last active July 2, 2024 19:06
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
@GaelVaroquaux
GaelVaroquaux / mutual_info.py
Last active June 18, 2023 12:25
Estimating entropy and mutual information with scikit-learn: visit https://github.com/mutualinfo/mutual_info
'''
Non-parametric computation of entropy and mutual-information
Adapted by G Varoquaux for code created by R Brette, itself
from several papers (see in the code).
This code is maintained at https://github.com/mutualinfo/mutual_info
Please download the latest code there, to have improvements and
bug fixes.