Praat logo

PraatR:

An architecture for controlling the phonetics software "Praat" with the R programming language

R logo

What is PraatR?

The following is adapted from the abstract for the original poster presentation about PraatR at the 167th Meeting of the Acoustical Society of America:

An increasing number of researchers are using the R programming language for the visualization and statistical modeling of phonetic data. However, R's capabilities for analyzing soundfiles and extracting acoustic measurements are still limited compared to free-standing phonetics software such as Praat. As such, it is typical to extract the acoustic measurements in Praat, export the data to a textfile, and then import this file into R for analysis. This process of manually shuttling data from one program to the other slows down and complicates the analysis workflow.

The present software architecture ('PraatR') is designed to overcome this inefficiency. Its core R function sends a shell command to the operating system that invokes the command-line form of Praat with an associated Praat script. This script imports a file, applies a Praat command to it, and then either brings the output directly into R or exports the output as a textfile. Since all arguments are passed from R to Praat, the full functionality of the original Praat command is available inside R, making it possible to conduct the entire analysis within a single environment. Moreover, with the combined power of these two programs, many new analyses become possible.

At present, PraatR can process 100 of Praat's different object classes. To these, 972 different commands can be applied. For the full list, see the List of supported commands.

If you use PraatR in your research, please cite the following publication (whose details be retrieved at any time after PraatR has been installed by typing citation("PraatR") at the R console):

Albin, A. (2014). PraatR: An architecture for controlling the phonetics software "Praat" with the R programming language. Journal of the Acoustical Society of America, 135(4), 2198.

Contacting the creator:

  • PraatR is still undergoing active development. If you encounter trouble when using PraatR, please do not hesitate to contact me. This will give me a better sense of what aspects of PraatR need to be worked on and improved first.
  • All of the code is hosted on GitHub, so please get in touch with me if you would like to help collaborate on further development of PraatR.
  • If you would like to receive announcements about the periodic updates made to PraatR, just send me an e-mail saying so an I will add you to the mailing list.

My e-mail address can be found at the very bottom of this page.


Installation

Getting PraatR set up is a simple two-step process.

Step 1 - Install PraatR: You can do so in one of two ways.

  • If you have the R package devtools installed (or if you don't mind running install.packages("devtools") to do so), you can install PraatR directly from GitHub with the following command.
  • devtools:::install_github("usagi5886/PraatR")

  • Otherwise, you can install PraatR by first downloading this zip file of the PraatR code (Version 2.4, Released 7/12/2016). Extract out its contents (a single folder named 'PraatR') to somewhere on your computer (e.g. your desktop). (The zip file itself is not needed and can be deleted when you are done extracting from it.) Then all you need to do is run a single line of code in R to install PraatR as an R package. The exact procedure depends on your operating system:
    • Windows: First, you need to open R as an administrator. To do so, go to the icon for R on your start menu ('start screen' in Windows 8) or desktop, right-click it, and select "Run as administrator". Click "Yes" to the User Account Control window that pops up. Then, run the following line of code, adjusting the path for the pkgs argument as needed so it points to the 'PraatR' folder you extracted from the zip file. (All of the components in this command are crucial, so make sure you haven't omitted anything.)
    • install.packages(pkgs="C:/Users/MyUsername/Desktop/PraatR/", lib=R.home("library"), repos=NULL, type="source")

    • Mac: Open R normally and run the following line of code, adjusting the path for the pkgs argument as needed so it points to the 'PraatR' folder you extracted from the zip file:
    • install.packages(pkgs="/Users/MyUsername/Desktop/PraatR/", repos=NULL, type="source")

    • Linux: Run R as root (e.g. by typing sudo R) and run the following line of code, adjusting the path for the pkgs argument as needed so it points to the 'PraatR' directory you extracted from the zip file:
    • install.packages(pkgs="/home/myusername/Desktop/PraatR/", repos=NULL, type="source")

  • Regardless of how you installed it, if everything works correctly, you should see something like the following in the R console.
  • * installing *source* package 'PraatR' ...
    ** R
    ** data
    *** moving datasets to lazyload DB
    ** inst
    ** preparing package for lazy loading
    ** help
    *** installing help indices
    ** building package indices
    ** testing if installed package can be loaded
    * DONE (PraatR)

Step 2 - Set up Praat: Finally, make sure Praat is set up on your computer in the right way for PraatR to work. (Due to recent changes made to Praat and how it interfaces with external programs like R, it is important that you use Praat version 6.0.8 or later.)

  • Windows: On the official Downloading Praat for Windows page, under section 1 "Downloading the Windows edition", download the appropriate zip file for your computer (either 64- or 32-bit). Extract its contents - the single file 'Praat.exe' - to inside the folder that R returns when you type find.package("PraatR") at the R console after you've completed Step 1. (This will be something like C:/Program Files/R/R-XYZ/library/PraatR, where 'R-XYZ' represents the version of R you have installed.) Place Praat.exe at the top level inside this folder, alongside files named "CITATION", "DESCRIPTION", and so on.
  • Mac: The latest version of Praat can be downloaded from the official Downloading for Praat for Macintosh page. Once installed, no additional steps are required as long as your Praat installation is located in /Applications/Praat.app.
  • Linux: The official Downloading for Praat for Linux page describes several ways to obtain the latest version of Praat. Once installed, make sure the Praat executable is in your PATH. If it's not (e.g., if you compiled Praat from source or if you downloaded the tar.gz file from the Praat website), this can be done in one of two ways:
    • Add the directory that the Praat executable is in to your PATH. To do so, you can use a command like export PATH="/home/myusername/praatstuff:$PATH". To make this change permanent, add that line of code to ~/.bashrc or ~/.profile.
    • Move the Praat executable into one of the directories in your PATH, e.g. /usr/local/bin. (You can check which directories your PATH contains by typing echo $PATH or, at the R console, Sys.getenv("PATH").)

That's it! Now you're ready to start using PraatR. See the Usage Tutorial page for a walkthrough of how to use it.


Release history

The following is the list of the updates to PraatR that have been made since its release. In order to ensure you can access its full functionality, you should always upgrade to the newest version. To see which version you have installed, type packageVersion("PraatR") at the R console.

  • Version 2.4 (July 12, 2016)
    • Updated package to be compatible with Praat version 6.0 and later
  • Version 2.3 (February 16, 2015)
    • Fixed bug in finding praatcon.exe on Windows if RStudio is installed
  • Version 2.2 (November 12, 2014)
    • Fixed bug in checking whether user's provided special output filetype is allowed
  • Version 2.1 (November 5, 2014)
    • Added support for Linux
    • Fixed bug where commands with parentheses would issue an error (Mac/Linux only)
  • Version 2.0 (October 24, 2014)
    • Released as an R package to allow simpler loading simply by calling library("PraatR")
    • Created documentation for the package, e.g. the help file displayed when typing ?praat
  • Version 1.2 (September 24, 2014)
    • Added additional input validation for enforcing input/output paths not to contain spaces
    • Added in functionality for additional 'special' output file types (e.g. WAV)
  • Version 1.1 (August 7, 2014)
    • Fixed problem with references to R library directory - .libPaths() vs. R.home("library")
  • Version 1.0 (May 5, 2014)
    • Initial public release

Note that the above information can be accessed at any time after PraatR has been installed by typing RShowDoc("NEWS",package="PraatR") at the R console. See also the commit history for the project on GitHub.


License

PraatR is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation - either version 3 or (at your option) any later version. This program is distributed in the hope that it will be useful, but without any warranty - without even the implied warranty of merchantability or fitness for a particular purpose. To see version 3 of the License at any time after PraatR has been installed, type RShowDoc("LICENSE",package="PraatR") at the R console.