To play a sound at the end of a script, you can use the beep() function from the beepr package as follows:
install.packages("beepr")
library(beepr)
beep(1)
You can play different sounds just by passing different numbers as the beep function argument.i.e.,
beep(3)
beep(5)
beep(2)
beep(6)
beep(7)
beep(8)
beep(1)
beep(3)