[英]How to load sound files and data in R for bioacoustic analysis (MonitoR)?
I am trying to follow this bioacoustics in R guide to help me run analysis on some frog chirps.我正在尝试遵循 R 指南中的这种生物声学,以帮助我对一些青蛙啁啾进行分析。 I am also looking at this MonitoR guide as they're trying to accomplish the same thing (using templates to run against sound files).
我也在看这个MonitoR 指南,因为他们试图完成同样的事情(使用模板来运行声音文件)。
As I have over 30,000 frog sound files of about 5 MB each, I've created a "dummy" folder with 20 random frog sound files in it and 5 template files.由于我有超过 30,000 个青蛙声音文件,每个文件大小约为 5 MB,因此我创建了一个“虚拟”文件夹,其中包含 20 个随机青蛙声音文件和 5 个模板文件。 I figured this would make things quicker and once I had my code fully working I would tweak the folder names.
我认为这会让事情变得更快,一旦我的代码完全工作,我会调整文件夹名称。
I am working in R Studio and the sound files are WAV ones.我在 R Studio 工作,声音文件是 WAV 文件。
I have loaded MonitoR and WarbleR using library(monitoR, warbleR)
and I think that has successfully loaded them.我已经使用
library(monitoR, warbleR)
加载了 MonitoR 和 WarbleR,我认为已经成功加载了它们。
Then I have set my working directory to that "dummy" folder with the 20 frog files and 5 chirp template files.然后我将我的工作目录设置为包含 20 个青蛙文件和 5 个 chirp 模板文件的“虚拟”文件夹。 I know that one has worked as when I call up
list.files()
they all appear.我知道当我调用
list.files()
时它们都出现了。
> list.files()
[1] "frog1.WAV" "frog10.WAV" "frog11.WAV"
[4] "frog12.WAV" "frog13.WAV" "frog14.WAV"
[7] "frog15.WAV" "frog16.WAV" "frog17.WAV"
[10] "frog18.WAV" "frog19.WAV" "frog2.WAV"
[13] "frog20.WAV" "frog3.WAV" "frog4.WAV"
[16] "frog5.WAV" "frog6.WAV" "frog7.WAV"
[19] "frog8.WAV" "frog9.WAV" "template_test1.WAV"
[22] "template_test2.WAV" "template_test3.WAV" "template_test4.WAV"
[25] "template_test5.WAV"
It is the second step of the first guide that I keep getting error messages on no matter how I try and tweak it.这是第一个指南的第二步,无论我如何尝试和调整它,我都会不断收到错误消息。
Step 1 has this:第 1 步有这个:
x<-c("warbleR", "monitoR")
That bit I understand as loading the packages, though I don't know what x and c are doing there...我理解为加载包的那一点,虽然我不知道 x 和 c 在那里做什么......
if(.y %in% installed,packages()[."Package"]) install,packages(y) require(y. character.only = T) })
I have no idea what that bit does... but including it or excluding it makes no difference to the error messages in the next step.我不知道那个位是做什么的......但是包括它或排除它对下一步中的错误消息没有影响。
Step 2 is creating templates and where I am getting stuck:第 2 步是创建模板以及我遇到的问题:
The guide says: # load sound files and data指南说: #加载声音文件和数据
data(list = c("Phae.long1", "Phae.long2", "Phae.long3", "Phae.long4", "selec.table"))
I am unsure what the selec.table
bit of the code does, but again, including or excluding it makes no difference to the error messages.我不确定代码的
selec.table
位是做什么的,但同样,包括或排除它对错误消息没有影响。
My attempted code is:我尝试的代码是:
data(list = c("template_test1", "template_test2", "template_test3", "template_test4", "template_test5", "selec.table"))
and it throws up the following errors:并引发以下错误:
Warning messages: 1: In data(list = c("template_test1", "template_test2", "template_test3", : data set 'template_test1' not found 2: In data(list = c("template_test1", "template_test2", "template_test3", : data set 'template_test2' not found 3: In data(list = c("template_test1", "template_test2", "template_test3", : data set 'template_test3' not found 4: In data(list = c("template_test1", "template_test2", "template_test3", : data set 'template_test4' not found 5: In data(list = c("template_test1", "template_test2", "template_test3", : data set 'template_test5' not found
警告消息:1:在 data(list = c("template_test1", "template_test2", "template_test3", : data set 'template_test1' not found 2: In data(list = c("template_test1", "template_test2", " template_test3", : 未找到数据集 'template_test2' 3: 在 data(list = c("template_test1", "template_test2", "template_test3", : 未找到数据集 'template_test3' 4: In data(list = c(" template_test1", "template_test2", "template_test3", : 未找到数据集 'template_test4' 5: In data(list = c("template_test1", "template_test2", "template_test3", : 未找到数据集 'template_test5'
I've tried steps suggested in both guides (with no success) and looking online for where I am going wrong, but I'm afraid I'm stumped.我已经尝试了两个指南中建议的步骤(没有成功)并在网上寻找我哪里出错了,但恐怕我很难过。 I've got a long road in R ahead of me for analysing this data set so any help anyone reading this has to give is greatly appreciated.
在分析这个数据集之前,我在 R 中还有很长的路要走,因此非常感谢任何阅读本文的人提供的帮助。 Thank-you.
谢谢。
I think that's the idea, though it takes forever to run on my laptop:我认为这就是想法,尽管在我的笔记本电脑上运行它需要很长时间:
library(monitoR)
library(tuneR)
file1 <- "Phae.long1.wav"
file2 <- "Phae.long2.wav"
file3 <- "Phae.long3.wav"
file4 <- "Phae.long4.wav"
viewSpec(file1)
wct1 <- makeCorTemplate(file1,
t.lim=c(0, 1.0),
wl = 300,ovlp=90,
frq.lim=c(0.1, 11), dens=1, name="file1")
wct2 <- makeCorTemplate(file2,
t.lim=c(0, 1.0),
wl = 300,ovlp=90,
frq.lim=c(0.1, 11), dens=1, name="file2")
wct3 <- makeCorTemplate(file3,
t.lim=c(0, 1.0),
wl = 300,ovlp=90,
frq.lim=c(0.1, 11), dens=1, name="file3")
wct4 <- makeCorTemplate(file4,
t.lim=c(0, 1.0),
wl = 300,ovlp=90,
frq.lim=c(0.1, 11), dens=1, name="file4")
ctemps <- combineCorTemplates(wct1, wct2, wct3, wct4)
audio <- readWave("mybigfile.wav")
audio <- changeSampRate(wchange = audio, sr.new = 22500)
cscores <- corMatch(survey = audio, templates = ctemps, write.wav = T)
cdetects <- findPeaks(cscores)
getDetections(cdetects)
plot(cdetects)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.