wavの波形表示
JuliaでWavファイルの波形をプロットする
module openwav using WAV using Formatting using Plots gr() function load_corpus(basedir, speaker) speaker_folder_name = "cmu_us_" * speaker * "_arctic" path = joinpath(basedir, speaker_folder_name, "wav", "arctic_a0001.wav") # load wav wavread(path, format="double") end function xrange(data, framerate) println("length", length(data)) x = range(0, length(data) - 1, step=1) / framerate end # http://www.speech.cs.cmu.edu/cmu_arctic/packed/ function main() resource_dir = normpath(joinpath(@__FILE__, "..", "..", "resources")) arctic_dir = joinpath(resource_dir, "CMU_ARCTIC") y, fs, nbit = load_corpus(arctic_dir, "aew") println(format("sampleing freq: {}", fs)) data = y[:,1] x = xrange(data, fs) p = plot() xlabel!("Time [sec]") ylabel!("Value [-1, 1]") println("x len{}", length(x)) println("y len{}", length(data)) plot!(x, data) png("sample.png") end main() end