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 / 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)
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 \
@r9y9
r9y9 / mlp3.jl
Last active August 29, 2015 14:19
mlp3.jl
sigmoid(x) = 1.0 ./ (1.0 + exp(-x))
dsigmoid(y) = y .* (1.0 - y)
type MLP3
W¹::Matrix{Float64}
b¹::Vector{Float64}
W²::Matrix{Float64}
b²::Vector{Float64}
end
@r9y9
r9y9 / vim_benchmark.sh
Created April 21, 2015 16:16
Easy vim benchmark (e.g: ./vim_benchmark.sh 10)
#!/bin/bash
# e.g. bash vim_benchmark.sh 10
LOGFILE=$(mktemp)
ITER=$1
function echo_mean_and_std() {
m=$(grep "editing files" $1 | awk 'BEGIN{m=0.0} {m+=$1} END{print m/NR}')
@r9y9
r9y9 / apr.jl
Created April 25, 2015 07:32
Apache Portable Runtimeをjuliaから呼んでみるテスト
const libapr = "./libapr-1.0"
@assert dlopen(libapr) != C_NULL
argc = Array(Cint, 1)
argv = Array(Ptr{Cchar}, 1)
env = Array(Ptr{Cchar}, 1)
# 引数なしの初期化
# ccall((:apr_initialize, libapr), Void, ())
@r9y9
r9y9 / d4c_badaccess_fix.diff
Created May 31, 2015 09:34
D4Cのメモリ違反をとりあえずfix
53c53
< double *waveform) {
---
> double *waveform, int waveform_length) {
66c66,68
< for (int i = 0; i <= half_window_length * 2; ++i)
---
> int upper_bound = half_window_length * 2 > waveform_length - 1 ?
> waveform_length - 1 : half_window_length * 2;
> for (int i = 0; i <= upper_bound; ++i)