Hello!
I was hoping to use beep() for some long-running code, but I noticed that beep() doesn't work when coding in RStudio or Positron via Posit Workbench.
I think the main issue is that the function looks for an audio driver that would not be present on Workbench.
Workbench runs Linux, so beep() is looking for the relevant audio driver that would not be there. I think the work around for this would be to add a check function like this:
is_rstudio_server <- function() {
info <- rstudioapi::versionInfo()
return(info$mode == "server")
return(FALSE)
}
Then use that to help beep() know when R and the underlying OS are running on a server (where audio drivers are unlikely) instead of a local machine. Then there would need to be some sort of intermediate function that runs the sound through the browser audio instead of trying to leverage an audio driver that is not there.
This second part is a little over my head, but AI alleges it's possible by: 1) making the audio files accessible as web assets via tools::tempdir(), 2) generating HTML/JS code that finds and plays the audio, then 3) triggering the temp HTLM file using rstudio::viewer(). No clue if this is close to the best solution or not though.
Hello!
I was hoping to use
beep()for some long-running code, but I noticed thatbeep()doesn't work when coding in RStudio or Positron via Posit Workbench.I think the main issue is that the function looks for an audio driver that would not be present on Workbench.
Workbench runs Linux, so
beep()is looking for the relevant audio driver that would not be there. I think the work around for this would be to add a check function like this:Then use that to help
beep()know when R and the underlying OS are running on a server (where audio drivers are unlikely) instead of a local machine. Then there would need to be some sort of intermediate function that runs the sound through the browser audio instead of trying to leverage an audio driver that is not there.This second part is a little over my head, but AI alleges it's possible by: 1) making the audio files accessible as web assets via
tools::tempdir(), 2) generating HTML/JS code that finds and plays the audio, then 3) triggering the temp HTLM file usingrstudio::viewer(). No clue if this is close to the best solution or not though.