我正在尝试使用tuneR包在R中播放wav文件。我不知道该函数的背景,但似乎它试图将wav文件保存到它无法访问的临时文件中。我正在执行以下操作:
> # install package if you don't have it
> install.packages("tuneR")
> library(tuneR)
> # load some WAV file
> mySound = readWave("Beethoven.wav");
> # plot it to see if things are working:
> plot(mySound)
> # play the sound
> play(mySound)
sh: /var/folders/qv/sw8_92hn4qg0rb5w40gz9mf40000gn/T//RtmpKU9kVN/tuneRtemp.wav: Permission denied
很明显,它无权访问此文件夹。如何更改此文件夹或授予R访问此文件夹的权限?
我正在使用带有RStudio 0.98.501的MacOSX 10.7.5。
最佳答案
使用OSX时,一个简单的解决方案是使用/usr/bin中的内置命令行音频播放器afplay。 (请参阅:http://hints.macworld.com/article.php?story=20081002080543392)
因此使用:
setWavPlayer('/usr/bin/afplay')