21 September 2007

A Praat Christmas

**************************
Please note that new versions of the Praat scripts on this page, as well as completely new scripts are available on my updated Praat scripts post.
**************************

A treasure trove of Praat scripts
Opening a large number of files in Praat is a tedious and time consuming process. Praat does not allow you to select all of the files in a directory and read them in at the same time. You can only read in one file at a time :(

Thankfully, Praat scripts can take care of many repetitive actions for you. Praat scripts are not magical. They don't do all of the work for you. Think of it this way: a script can carry out any Praat command that you can, which can save you many mouse clicks. A script cannot do anything that requires human judgment, such as labeling segments. When using a script, you have to know exactly what it is doing.

Here are the Praat scripts that I have used:

1. textgrid-maker.praat - This script is used when creating text grids. It will read in all of the .wav files in a folder one at a time, create a text grid, and open the editor for you. Once you have labeled the segments, click the Continue button. The text grid will be saved and the editor will close. Then the next .wav file and text grid will open in the editor. This cycle will continue until you run out of .wav files.

2. textgrid-reviewer.praat - This script is used when checking or modifying existing text grids. It will read in all of the .wav files and text grids in a folder, and open them one at a time in the editor. When you have finished making changes to your labels, click Continue. The script will stop running when you run out of .wav files and text grids.

3. duration-logger.praat - Will output all of the durations of labeled segments to a text file.

4. segment-start-end-duration-dB.praat - As the name suggests, this script will output the start, end, duration and average loudness (in dB) of labeled segments to a text file.

5. xlang_measurements.praat - This script is an extended version of segment-start-end-duration-dB.praat, and will measure formants, f0, and amplitude at 3 points in the vowel (25%, 50%, and 75%).

6. target-chopper.praat - Will chop out your target word/segments, apply onramping for 10ms and offramping for 20ms (to fade your sound file in and out smoothly - without audible clipping), and create a new set of .wav files containing the target only. This script would be used when you are generating stimuli for a perceptual experiment.

For more Praat scripts, I refer you to Katherine Crosswhite's excellent Praat script page.

Praat syntax highlighting for Notepad++
The first time you see a Praat script, you may feel the urge to rip your hair out by the roots in despair. Don't worry. A little colour goes a long way.

Syntax highlighting changes the colour and font of sections of text to improve readability. It is a common feature in advanced text editors such as Notepad++. It is easy to find syntax highlighting for HTML or programming languages, or even Matlab, but syntax highlighting for Praat is a different story. This is because not many people around the world use Praat (certainly not many non-Dutch-non-Linux users).

I know of three text editors that have Praat syntax highlighting:
1. Ultra Edit - which costs $US50
2. TextPad - which costs $US30
3. Emacs - which is horrible (sorry Christian, but it is).

So, I have created a Praat syntax highlighting file scheme for the excellent (and free) Notepad++. You will need to:
1. install Notepad++
2. download the Praat syntax highlighting scheme
3. save the userDefineLang.xml file to C:\Documents and Settings\InsertYourUserNameHere\Application Data\Notepad++\

.praat and .script files will automatically open with Praat syntax highlighting in Notepad++. You can apply syntax highlighting to any file manually by selecting the syntax scheme from the Languages menu within Notepad++.

By downloading and using my Praat syntax highlighting scheme, you agree to become a beta tester :) So, if you notice any problems or inconsistencies in the Praat syntax highlighting, please post a comment below so that I can improve the consistency of the colouring.

Praat auto-completion for Notepad++
Autocomplete is a feature where the program predicts a word or phrase that the user wants to type in without them actually having typed it in completely. In Notepad++, the autocomplete list box is displayed using Ctrl+Space. The list is sorted alphabetically, and filters suggestions as you type. For example, if you type re and then press Ctrl+Space, only words beginning with re will be suggested.

I have converted a Praat autocomplete file that was originally designed for the powerful, but expensive, Ultra Edit, so that it is compatible with (the also excellent but free) Notepad++. You will need to:
1. install Notepad++ (if you haven't already done so)
2. Download the Praat autocomplete file
3. save the praat.api file to C:\ProgramFiles\Notepad++\plugins\APIs\
Note: this is the folder where you installed Notepad++. This is different to where the syntax highlighting file is stored.

Please communicate with me by posting a comment below, rather than emailing me. This way, others can refer to my answers here, saving me many hours of responding to similar emails.
Blogged with Flock

15 comments:

Anonymous said...

Feedback #1

I find the highlighting for the folder close items a little off-putting.
I'd prefer it to be the same colour as the folder open ones.

Mark Antoniou said...

Folder open and folder close items are now the same colour. Re-download the userDefineLang.xml file and overwrite the old off-putting one.

Anonymous said...

Hi there,
I tried to use the auto complete function. Alas, Notepad++ seems to require a .xml file for that feature, which is also slightly differently formatted. Any pointers?

Cheers,

Frank

Mark Antoniou said...

Notepad++ uses .api files. There are a bunch of them available for download from the Notepad++ homepage http://notepad-plus.sourceforge.net/uk/download.php (scroll down to API files). However, there is no Praat autocomplete available there. That's why I made the one that you can download above. Make sure you put it in the correct folder or it won't work. You don't need an XML file — I'm not sure where that information came from. I just double-checked the api file with the latest version of Notepad++ and it works. Let me know if you have any problems.

Morpheus said...

This is absolutely GREAT!! Thank you so much for your effort!!

Unknown said...

Thanks Mark, that exactly what I was looking for!

I don't know exactly when it stopped being supported, but .api files don't seem to work anymore with newest versions of Notepad++ (the auto-completion HowTo says that the extension has to be XML).

I converted your .api file to XML and copied it to the APIs folder, and everything works perfectly now: http://www.box.net/shared/4ptupdydat
However, with the frequent updates of Praat, this list of functions is probabely not the most up to date. When you built your .api file, did you find a way to automatically export the complete list of Praat function?

Mark Antoniou said...

Thanks for the info Nicolas. Guess this post is starting to show it's age. I'll have to update it when I get a chance.

In regards to your question, I think that I copied the list of Praat functions from a similar file that had been created for a different text editor. Sorry, it was too long ago, I cannot remember where I got that list from :(

Alvin Chen said...

Mark, thank you very much for these tools!!! Just a quick question. Could you guide me how to send all the praat script from Notepad++ to praat console? Is it possible??

Emma E said...

Thanks, I was just working on some praat scripting and wondered if anyone had put together one of these. Any reason you haven't posted this on the User Defined Language List?

Mark Antoniou said...

I don't know what that is, Emma.

At the top of this post is a link to my latest Praat script post. There are many more scripts available for download there.

Jacques said...

Thanks Mark,
you helped me a lot today!
Good job.

Laura said...

Hi Mark,

your scripts a real gift ! Thanks for the effort.

I wonder about something in the getmeasurement.praat script, what was the reason to put this line
if segment$ == "aa" or segment$ == "Ha" or segment$ == "a"

there? Indeed I have textgrids that contain "a" segments, still I wondered why your script takes special care of a, ha and aa

Thanks in advance!

Laura

Mark Antoniou said...

I'm glad that you found the scripts to be helpful.

That script was created for a project that dealt with recordings of a language other than English. It was so long ago that I don't even remember which language. Basically, there were three types of vowels, denoted by a, aa and Ha. So, the IF statement is really just saying "if the segment is a vowel" then do something to it.

ETAiki said...

Thank you for making available very useful syntax highlighting for Notepad++.

One thing I noticed was that the folding keywords (if,for,else etc.) are listed in code1 style. This causes "if" in "difference" (used as a variable name) is also highlighted making it a bit ditracting. Moving those to code2 style fixed it.

I may be missing something, but I decided to post here anyway just in case...

Emma E said...

New workstation...new download of praat syntax highlighting for Notepad++...

Several years belated, the "User Defined Language List" I referred to is the N++'s SourceForge repository for user-contributed syntax highlighting rules. I thought it would be useful to include there as well.

Thanks!

(http://sourceforge.net/apps/mediawiki/notepad-plus/?title=User_Defined_Language_Files)