Play a sound at the end of R script in Windows command line

In my post about favorite RStudio tips and tricks, I mentioned sounds that could be played during R script execution. It works great but doesn’t make a sound after running R script from the Windows command line. Here is how to do that by using PowerShell and adding additional lines in the same batch file.

Play beep with the help of PowerShell

With the help of two parameters in the brackets, modify the frequency and duration of the beep sound.

Try to combine beeps and compose some sort of melody like this.

There is possible that after R script execution, you can play .wav files with System.Media.SoundPlayer.

Readout loud the text after R script is executed

That can be done with PowerShell by using System.Speech.Synthesis.SpeechSynthesizer.

It is interesting how speech synthesizer works. Only if I write R file name without capital letter at the beginning, it is pronounced properly.

Choose one of these sound solutions and add next to the R script execution in the Windows batch file or command line.

Play sound or speech after R script execution in RStudio

If you want to run R script in RStudio and play sound or speech from there, you can do that by running PowerShell script in a separate batch file. Check out this post to learn how.

0 comments on “Play a sound at the end of R script in Windows command line

Leave a Reply

Your email address will not be published. Required fields are marked *