Created
April 4, 2021 14:04
-
-
Save tetlabo/85ce0ec1f347b6399eeee637c916371b to your computer and use it in GitHub Desktop.
MP3データを読み込み、スペクトログラムを描画する
This file contains hidden or 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
library(tuneR) | |
library(seewave) | |
mp3_files <- list.files(path = "mp3/", pattern = "*.mp3") | |
for (i in 1:length(mp3_files)) { | |
name <- gsub("mp3", "png", mp3_files[i]) | |
voice <- readMP3(file.path(paste0("mp3/", mp3_files[i]))) | |
# スペクトログラムの描画 | |
png(filename = name, width = 3200, height = 1600, res = 240) | |
par(cex.lab = 1.3, cex.axis = 1.3) | |
spectro(voice, flim = c(0, 10), osc = TRUE) | |
dev.off() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment