rasmusab / beepr Goto Github PK
View Code? Open in Web Editor NEWThe package that sounds as it is called.
The package that sounds as it is called.
Dunno if you're taking inclusion requests, but these classics would be top for me:
Tada
Critical Stop
I love your package and use it all the time. I'd love it if you could add "quiet hours" logic as to whether to actually beep or not. For long runs I kickoff before bed I sometimes forget to mute my machine and have woken up to the beep!
The first pass implementation of this would be to just pass a character vector to beep
like c("22:00", "07:00")
(defaults to NULL
, i.e., doesn't respect quiet time so as not to break current usage) and then compare against "now" (chron::times
might be a good approach internally to convert the input and compare it to the Sys.time
). This is pretty straight forward and I could submit a PR if this is something you'd be willing to add.
A next step off of this would be to build an options
argument that can be set globally for the package so you don't have to pass it in with each beep
call. I've seen this in other packages, but haven't done it myself, so I'd have to research a bit more how it is done.
Anyway, let me know what you think.
Hi. Im using Arch Linux with Rstudio.
Unfortunately, beepr is not working.
I run beep() function and nothing happens. My audio cards are ok.
Any idea of whats happening?
This works on local desktop version of R. I am not able to hear anything when I run this function on the R Studio Server. Any suggestions what I need to do get it work on the Server ?
The 'stringr' package depends on 'stringi', which is quite heavy and takes a long time to install from source. Looking at the source code, 'beepr' uses:
stringr::str_detect()
stringr::str_replace_all()
stringr::str_trim()
These can easily be replaced by base::grepl()
and base::gsub()
, e.g.
str_detect <- function(string, pattern, ignore_case = TRUE) {
grepl(pattern, string, ignore.case = ignore_case)
}
str_replace_all <- function (string, pattern, replacement) {
gsub(pattern, replacement, string)
}
str_trim <- function(string) {
gsub("(^[[:space:]]+|[[:space:]]+$)", "", string)
}
Doing so would make 'beepr' depend on only 'audio'.
The package is awesome! I just have a suggestion. I think that an incredible sound missing is the chorus of Take on Me (A-Ha). Due to fact that Take on Me is an anthem of a generation and specially important for ecologists in Brazil that use R in their daily routine and are very moved with the potential use of ping().
The ping command does not work for me when running R at the Linux command line. It does work in RStudio.
After exploring a bit, I found that, while the function 'ping' loads after I call 'library(pingr)', none of the other functions are loaded into the session. So 'ping()' fails to make any sounds.
This is in R v3.1.0 beta (2014-03-28 r65330) -- "Spring Dance"
in Linux Mint 14.
It could be convenient to be able to call beep(sound)
as a noop, i.e. such that it returns immediately if sound = -1
or `sound = "none".
It looks like it is possible to use beepr with RStudio server but i could not find a tutorial. This is what I get when I try to run it:
> beepr::beep(4)
Warning message:
In value[[3L]](cond) :
beep() could not play the sound due to the following error:
Error in play.default(x, rate, ...): no audio drivers are available
Could you point me in the right direction?
4,6,7,11 echos a duplicate portion of the soundbite after its finished playing
called from console in RStudio:
echos | function calls |
---|---|
4 | beepr::beep(4) |
6 | beepr::beep(6) |
7 | beepr::beep(7) |
11 | beepr::beep(11) |
I've just installed beepr on RStudio Server, i read somewhere i would work, but it isn't working.
Is there a special config or RS Server isn't supported?
thanks.
On Windows 10 x64, R 4.0.2, Rstudio 1.3.1056, some of the sounds seem to have a stutter, repeating the last millisecond of the sound.
By ear, I can hear it on "complete", "ready", "shotgun", and "sword".
It's trivial and in no way harms the functional purpose of the (very useful!) package, but just thought it best to report this.
Hi,
Thank you for this useful small package.
The beep function doesn't work anymore on my computer, returning that "no audio drivers are available"
I've recently upgraded my Linux Fedora box from release 21 to 22, and also upgraded all my R packages. So, I don't know if the problem is related to some R packages or the Linux distribution.
It comes out that the problem is not related to the audio driver, but that it finds its origin in the "is_wav_fname" function, which returns FALSE even if fname is a valid wav file.
"is_wav_fname" uses "ignore.case(".wav$"), which is deprecated.
So, I replaced
"str_detect(fname, ignore.case(".wav$"))
by
"str_detect(fname, fixed(".wav", ignore_case=TRUE))
and this solves the problem.
Bart
Cool package !!!
I have a suggestion. I'd like to ping local wave file.
So, could you add "path" parameter to "ping" function?
Like this
ping <- function (sound = 1, path = NULL, expr = NULL) {
[...]
if (!is.null(path)) {
sound_path <- path
}
else {
sound_path <- system.file(paste("sounds/", sound_fname,
sep = ""), package = "pingr")
}
play_file(sound_path)
}
Unsure if there's some solution that already exists, but it would be great if I could get this to play a sound when a markdown document has finished knitting.
Thanks for a great package!
Geoff
Hi Rasmus
Nice package.
Can you tag the current release as v0.1 so I can ensure I always explicitly pull this version using install_github(rasmusab/[email protected])
as opposed to a development version.
Also any plans to get it on CRAN?
Thanks
Joe
beep(url)
uses:
Line 66 in 07c898d
to download the file. However, download.file()
defaults to mode = "w"
(text mode), which works fine on Linux and macOS, but on MS Windows, it'll automagically turn \n
(LF) into \r\n
(CRLF) and vice versa, also in binary files. To avoid this, explicitly specify mode = "wb"
, i.e.
if(download.file(sound, destfile = temp_file, mode = "wb", quiet = TRUE) == 0) { # The file was successfully downloaded
hi,
I am trying to use beepr to let me know when Rscripts have finished, but beepr doesn't appear to work when used this way. I have created a stack overflow question about this.
https://stackoverflow.com/questions/49087632/no-sound-from-beepr-in-rscript
But thought it better to ask at the source.
Is this even possible? If you can offer some direction, I would be happy to try tackle this also.
Since sounds used within beepr are from Final Fantasy, Warcraft 2, Facebook, DOOM, etc., I think it may clash with the validity of the package license when the files are included in the distribution of the package itself.
I think removing them would help the distribute-ability of the package and help keep compliance with the license. Instead, they can just be made links to resource files to other places, since the package supports playing sounds from a url.
Like
beep("http://www.wolfensteingoodies.com/archives/olddoom/sounds/dsshotgn.wav")
instead of
beep(7)
Please consider adding fields URL
and BugReports
to the DESCRIPTION file to make it easy to locate this repo, e.g. from https://cran.r-project.org/package=beepr.
Hi,
Since Rstudio 1.2, we can run different jobs in background. (See this article)
I tried to run a small script with a beep()
call but I don't hear anything.
Example script
library(beepr)
Sys.sleep(2)
beep(1)
cat("Done \n")
Do you think it's possible to tweak Rstudio or the package in a way this can work ?
PS : Awesome package, thanks a lot !
I love this package and use it a lot! I recently tried it in a Shiny app and could not get the sound to go in a deployed app. It works perfectly when I use shiny::runApp() from Rstudio. My deployed Shiny app's log shows the package loading fine and no errors related to the Beepr package. Is there something fundamental to a Shiny app that would prevent it from working?
Hi, it would be great if you can include aplay instead or apart from vlc, cause it is almost ever installed and it is a very little program, anyways I tried to and it seems no hard, I could fork it if you want:
alsaplay <- function(fname) {
system(paste("aplay -q", fname),
ignore.stdout = TRUE, ignore.stderr=TRUE,wait = FALSE)
invisible(NULL)
}
Perhaps it's specific to my system, but no sound comes from paplay when playing wav files (no error also). play_aplay() and play_vlc() both work.
Maybe aplay could be first in the if/else hierarchy of play_file(). Or add an option to choose which program to use with beep().
Hi Rasmus, thanks for the function, I use it in almost everything. However I've just realised it may have been the cause of all my crashed R sessions - please see this bug which RStudio team just closed cos it's probably not specific to them i.e. is an R core issue:
rstudio/rstudio#3549 (comment)
Thanks!
To make it easier to find this GitHub repos from CRAN package pages and elsewhere, please consider adding URL
and BugReports
fields to the DESCRIPTION file.
Hi, I'd like to mention an issue I encountered when using beepr
on a Windows 10 and 11 machines. I should mention that the Windows 11 machine is equipped with 16gb RAM, i7 12th Gen Intel and an RTX 3070. Also, I am using R 4.1.1
on both machines. When performing some analysis (e.g., GWR
) and I am using the beepr
package after some code chunk, in order to notify me that the chunk completed the analysis, R
crashes right after the notification sound of beepr
. If I don't use the notifications from beepr ``R
continues without any problem. The same happened with other Windows machines (I tried it with my friends laptop). Any ideas of why might that happens? Thanks
> beepr::beep( "http://www.wavsource.com/snds_2014-07-06_8028356563048763/sfx/ocean.wav" )
Message d'avis :
In value[[3L]](cond) :
beep() could not play the sound due to the following error:
Error in load.wave(fname): incomplete file
Seems to be related to the audio
package which does not think the file is fine.
I can get this to work
download.file( "http://www.wavsource.com/snds_2014-07-06_8028356563048763/sfx/ocean.wav",
"/tmp/ocean.wav" )
system( "open /tmp/ocean.wav" )
This uses iTunes which you can definitely assume is available. Otherwise we could use vlc, but it might not be on the PATH
which is what nchar(Sys.which("vlc")) >= 1
cares about. Could do e.g. :
system( "open -a vlc /tmp/ocean.wav" )
Hello! This is a great package.
What do you think about an extension to only beep on error? Something along the lines of:
library(beepr)
beep_on_error <- function(inp, error_beep = 9) {
q_inp <- substitute(inp)
msg <- paste0("An error occurred in ", deparse(q_inp))
e <- simpleError(msg)
tryCatch(inp, error = function(e) {
message(paste0(msg, ": ", e$message))
beep(error_beep)
})
}
beep_on_error(log("foo"))
#> An error occurred in log("foo"): non-numeric argument to mathematical function
beep_on_error(log(3))
#> [1] 1.098612
This doesn't work with the forwards pipe but maybe it's worth looking into. If you like, I'm happy to submit a PR.
I'm running Linux (Ubuntu 13.10), and I installed and tried out ping. I ran the
ping( )
function a few times from the Rstudio command tab, and now I have several 'ping!' noises on an infinite loop.
I think my VLC is set up to repeat a file by default; It's probably possible to use the command line flag --no-loop to fix this.
Cool idea for a package by the way :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.