Created
January 13, 2020 11:11
-
-
Save YuheiNakasaka/7824a0385ee735eb3c46aff732ce5b2c to your computer and use it in GitHub Desktop.
適当な音声ファイルをffmpegでwavにしてsoxでspectrogramを作るやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
start = 0 | |
sec = 2 | |
if ARGV.length == 3 | |
file = ARGV[0] | |
start = ARGV[1] | |
sec = ARGV[2] | |
else | |
file = ARGV[0] | |
end | |
filename = File.basename(file, '.*') | |
if !File.exist?(file) | |
raise "File not exists" | |
end | |
wav_file = "#{filename}.wav" | |
system("ffmpeg -loglevel fatal -y -i #{file} -ac 1 #{wav_file}") | |
system("sox #{wav_file} -n trim #{start} #{sec} rate 12k spectrogram -y 300 -z 65 -o #{filename}.png") | |
puts "#{filename}.png successfully created" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment