Is there a way to make R beep/play a sound at the end of a script?

Solution 1:

I have a package (beepr) with the sole purpose of making notification sounds in R which should work cross-platform. Run the following to install beepr and make a sound:

install.packages("beepr")
library(beepr)
beep()

More info at github: https://github.com/rasmusab/beepr

Solution 2:

alarm()

The alarm function. It works by sending \a to the console

Solution 3:

On MacOSX you can let the computer speak:

system("say Just finished!")

and you can also change the artificial voice that will speak:

system("say -v Kathy Just finished!")

You can pick any voice that is available on your computer. On Yosemite you can see which voices are installed in System Preferences -> Dictation & Speech -> Text to Speech.