R语言:如何在我自己的wav文件中使用Specan函数?

时间:2018-10-24 12:04:50

标签: r

我正在尝试使用warbleR软件包中的specan函数。我想将自己的wav文件作为该函数的参数传递。我在文档中仅看到一个示例,该示例说明不多。

wave_file <- readWave("C:/Users/ABC/Downloads/file_example_WAV_1MG.wav", from = 1, to = Inf, units = c("seconds"), header = FALSE, toWaveMC = NULL)
head(wave_file)
mono_file <- mono(wave_file, which = c("both"))
head(mono_file)
auto_file <- autodetec(X = "C:/Users/ABC/Downloads/file_example_WAV_1MG.wav")
head(auto_file)
dataframe <- data.frame(list = c("sound.files", "selec", "start", "end"))
dataframe <- data.frame(wave_file, "abc", 1, Inf)
dataframe

# Existing Example found in R docs
#setwd('C:/Users/ABC/Downloads')
#data1 <- data(list = c("Phae.long1", "Phae.long2", "Phae.long3", "Phae.long4", "selec.table"))
#writeWave(Phae.long1,"Phae.long1.wav")
#writeWave(Phae.long2,"Phae.long2.wav")
#writeWave(Phae.long3,"Phae.long3.wav")
#writeWave(Phae.long4,"Phae.long4.wav")
#writeWave(Phae.long1,"file_example_WAV_1MG.wav")
#writeWave(Phae.long2," ")
#writeWave(Phae.long3,"1")
#writeWave(Phae.long4,"Inf")

getwd()


#file <- specan(X = selec.table, bp = c(0, 22))
#head(file)

file <- specan(X = dataframe, bp = c(0,22))

如何将自己的.wav文件作为specan函数的参数?

1 个答案:

答案 0 :(得分:0)

不要将实际的wav文件传递到数据帧,而是传递该文件的名称。因此您的代码应如下所示:

dataframe <- data.frame(list = c("sound.files", "selec", "start", "end"))

dataframe <- data.frame("file_example_WAV_1MG.wav", 2, 1, 20)

names(dataframe) <- c("sound.files", "selec", "start", "end")

a <- specan(X=dataframe, bp=c(0,22))

然后您可以查看a。提取的特征将存储在数据框中。确保文件存储在工作目录中。