Skip to content

Instantly share code, notes, and snippets.

View r9y9's full-sized avatar
:shipit:
( ˘ω˘ ) zzz

Ryuichi Yamamoto r9y9

:shipit:
( ˘ω˘ ) zzz
View GitHub Profile
@r9y9
r9y9 / gap_benchmark.jl
Last active June 13, 2017 16:10
GaP-NMF short benchmark scripts for Python and Julia.
push!(LOAD_PATH, ".")
using BNMF
using PyCall
# bp_nmf のコードと比較するために、librosaを使う
@pyimport librosa
function spectrogram()
x, ss = librosa.load("test.wav", sr=16000)
X = abs(librosa.stft(x, n_fft=1024, hop_length=256))
@r9y9
r9y9 / user.behaviors
Created August 26, 2014 01:34
user behaviors of LightTable
;; User behaviors
;; -----------------------------
;; Behaviors are stored as a set of diffs that are merged together
;; to create the final set of functionality that makes up Light Table. You can
;; modify these diffs to either add or subtract functionality.
;;
;; Behaviors are added to tags, objects with those tags then automatically gain
;; whatever logic the behavior imparts. To see a list of user-level behaviors,
;; start typing a word related to the functionality you want in between the square
;; brackets (e.g. "theme").
@r9y9
r9y9 / build.sh
Last active August 29, 2015 14:06
JuliaTokyo #2 で使う資料に載せるコード。BinDeps.jl の使用例
#!/bin/bash
function install_libsndfile() {
name=libsndfile-1.0.25.tar.gz
wget -O $name http://www.mega-nerd.com/libsndfile/files/$name
tar xzvf $name
cd `basename $name ".tar.gz"`
./configure --prefix=$PWD/..
@r9y9
r9y9 / updateE.jl
Created November 1, 2014 04:13
E-step of ML estimation of hidden Markov models
function updateE!(hmm::HMM,
Y::AbstractMatrix, # shape: (D, T)
α::Matrix{Float64}, # shape: (K, T)
β::Matrix{Float64}, # shape: (K, T)
γ::Matrix{Float64}, # shape: (K, T)
ξ::Array{Float64, 3}, # shape: (K, K, T-1)
B::Matrix{Float64}) # shape: (K, T)
const D, T = size(Y)
# Gaussian prob.
@r9y9
r9y9 / GaussianHMM.jl
Created November 1, 2014 06:56
Hidden Markov Models with Gaussian observation
# Hidden Markov Models
using Distributions
type HMM
K::Int # number of possible states
μ::Array{Float64, 2} # shape (D, K)
π::Array{Float64, 1} # shape (K)
A::Array{Float64, 2} # shape (K, K)
Σ::Array{Float64, 3} # shape (D, D, K)
@r9y9
r9y9 / download_cmu_arctic.sh
Last active January 5, 2021 11:07
CMU ARCTIC download script
#!/bin/bash
# This is a yet another download script for the cmu arctic speech corpus.
# The corpus will be downloaded in $HOME/data/cmu_arctic/
location=$HOME/data/cmu_arctic/
if [ ! -e $location ]
then
echo "Create " $location
backward_plan2{T<:Union(Float32, Float64)}(X::AbstractArray{Complex{T}}, Y::AbstractArray{T}) =
FFTW.Plan(X, Y, 1, FFTW.ESTIMATE | FFTW.PRESERVE_INPUT, FFTW.NO_TIMELIMIT).plan
function istft2{T<:Union(Float32, Float64)}(S::AbstractMatrix{Complex{T}}, wlen::Int, overlap::Int; nfft=nextfastfft(wlen), window::Union(Function,AbstractVector,Nothing)=nothing)
winc = wlen-overlap
win, norm2 = compute_window(window, wlen)
if win != nothing
win² = win.^2
end
nframes = size(S,2)-1
@r9y9
r9y9 / converter.py
Created February 14, 2015 16:50
こんな感じでVCできたらいいなぁという設計の例
"""
こんな感じでVCできたらいいなぁという設計の例
"""
class Analyizer(object):
"""
音声分析のインタフェース
"""
function dft{T}(x::Vector{T})
N = length(x)
X = Array(Complex{T}, N)
for k = 1:N
s = 0.0 + 0.0im
for n = 1:N
s += x[n] * exp(2π * (-im) * k * n / N)
end
X[k] = s
end
@r9y9
r9y9 / hts_demo_download.sh
Created March 14, 2015 11:59
Download HTS demo version 2.3 beta
#/bin/bash
# requirement: curl
base=http://hts.sp.nitech.ac.jp/archives/2.3beta/
for name in \
HTS-demo_NIT-ATR503-M001.tar.bz2 \
HTS-demo_CMU-ARCTIC-ADAPT.tar.bz2 \