Is there a way to make R beep/play a sound at the end of a script?
alarm()
The alarm function. It works by sending \a
to the console
Make R/RStudio beep play after *every* command
You want addTaskCallback.
addTaskCallback(function(...) { system("say done"); TRUE }, name = "announce when done")
Have fun!
How to make a Shiny App beep / play a sound after a reactive event?
The beep.wav
file should be in the /www
folder, located in the same directory as the shiny app for the audio Tag to work, see following post.
This works :
library(shiny)
ui <- fluidPage(
tags$head(tags$script(src = "message-handler.js")),
actionButton("dobeep", "Play sound")
)
server <- function(input, output, session) {
observeEvent(input$dobeep, {
insertUI(selector = "#dobeep",
where = "afterEnd",
# beep.wav should be in /www of the shiny app
ui = tags$audio(src = "beep.wav", type = "audio/wav", autoplay = T, controls = NA, style="display:none;")
)
})
}
shinyApp(ui, server)
How do I make JavaScript beep?
It's not possible to do directly in JavaScript. You'll need to embed a short WAV file in the HTML, and then play that via code.
An Example:
<script>
function PlaySound(soundObj) {
var sound = document.getElementById(soundObj);
sound.Play();
}
</script>
<embed src="success.wav" autostart="false" width="0" height="0" id="sound1"
enablejavascript="true">
You would then call it from JavaScript code as such:
PlaySound("sound1");
This should do exactly what you want - you'll just need to find/create the beep sound yourself, which should be trivial.
Python: Making a beep noise
On Windows, if you want to just make the computer make a beep sound:
import winsound
frequency = 2500 # Set Frequency To 2500 Hertz
duration = 1000 # Set Duration To 1000 ms == 1 second
winsound.Beep(frequency, duration)
The winsound.Beep()
can be used wherever you want the beep to occur.
Notification when R finishes running?
Try alarm()
See this post (maybe tweet that it's done?)
Related Topics
How to Check If Object (Variable) Is Defined in R
Why Is Enquo + !! Preferable to Substitute + Eval
Arrange Base Plots and Grid.Tables on the Same Page
Display Custom Image as Geom_Point
Handling Java.Lang.Outofmemoryerror When Writing to Excel from R
Plot Polynomial Regression Curve in R
How to Run R on a Server Without X11, and Avoid Broken Dependencies
Rotate a Matrix in R by 90 Degrees Clockwise
Short Formula Call for Many Variables When Building a Model
How to Take Pairwise Parallel Maximum Between Two Vectors
Remove Groups with Less Than Three Unique Observations
How to Name the "Row Names" Column in R
R Convert Zipcode or Lat/Long to County
Why True == "True" Is True in R