1 / 24

Praat scripting basics

Praat scripting basics. Pauline Welby Col áiste na Tríonóide, Baile Átha Cliath (Irlanda) welbyp@tcd.ie. Praat scripting. Praat is a phonetic analysis software program Available for many different platforms (Windows, Macintosh, Unix, Linux)

guinevere
Download Presentation

Praat scripting basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Praat scripting basics Pauline Welby Coláiste na Tríonóide, Baile Átha Cliath (Irlanda) welbyp@tcd.ie

  2. Praat scripting • Praat is a phonetic analysis software program • Available for many different platforms (Windows, Macintosh, Unix, Linux) • Can be downloaded (for free) from www.praat.org. • Includes a scripting language

  3. Praat scripts • Do anything you can do in Praat by hand • Open, save, rename files, convert formats, etc. • Measure formants, F0, etc. • Resynthesize duration, F0, etc. • Draw figures • Label • Present stimuli and collect responses

  4. Why script in Praat? • saves time • prevents errors (typos, data transfer errors) • makes errors easier/faster to correct • allows you to play around with different parameters

  5. Detailed Praat scripting tutorial Available on the web (Praat web page): http://www.fon.hum.uva.nl/praat/manual/Scripting.html or From within Praat In objects window: Help | Praat intro Search: scripting

  6. Keep in mind… • It’s easier to adapt an existing script (your own or someone else’s) than to write one from scratch. • Many scripts freely available on the WebCheck sites: • http://www.icp.inpg.fr/~welby/PAGES/praat.html (Pauline Welby, in French and English) • http://www.cavi.univ-paris3.fr/ilpga/ED/student/stcg/#E (Cedric Gendrot, in French) • http://www.helsinki.fi/~lennes/praat-scripts(Mietta Lennes, in English) • http://www.icp.inpg.fr/%7Eloeven/ScriptsPraat.html(Hélène Loevenbruck, in French) • http://www.cphling.dk/pers/johtnd/praat/my_praat.htm(John Tøndering, in English) • http://www.ling.ohio-state.edu/~kyoon/scripts/praat(Kyuchul Yoon, in English) Also, try a Google search.

  7. Opening a Praat script • To open an existing script in Praat: Praat | Open script... • Note: Different from opening sound files, TextGrid files etc. (Read | Read from file…)

  8. Let’s try it… • Open (read in) all sound files in a directory • Can do by hand (slowly and painfully) • Or use a script: readin-files-simple.praat - Praat | Open script... - Navigate to correct directory and find readin-files-simple.praat

  9. Open the script: Starter1.praat

  10. Elements in a script Comments • Allow you to give descriptions of what each part of a script does • A very good idea! Helps you (and other users) understand how the script works • Also useful for testing and diagnostic purposes • Praat comment character: # • Praat ignores anything to the right of # • This line reads in a sound file: Read from file... finger.wav • This line does nothing! #Read from file... finger.wav

  11. Elements in a script • Objects (are manipulated) • everything in object window (at left) • files • numbers • strings (letters, etc.) …

  12. Open the script: Starter2.praat

  13. Elements in a script • Variables (a type of object) • Store values • Examples: • ifile • numberOfFiles • fileName$ • Types: number, string (text), boolean (yes/no or 1/0) • Naming conventions: • begin with lowercase letters • no spaces • string variables must end in ‘$’

  14. Open the script: Starter3.praat

  15. Elements in a script • Functions (exist in Praat window menus) • Read from file… • Write to file… • Remove • Play Some functions act on only certain types of objects and in certain environments (e.g., Edit window). Naming conventions: - always begin with uppercase letters - may have spaces - functions that take arguments end in dots (…)

  16. Elements in a script • Commands (specific to Praat scripting language) • form, endform • select • print • clearinfo • if, endif • for, endfor … Naming conventions: - start with lowercase letters - one word

  17. Creating a Praat script from scratch • To create a new script:Praat | New script

  18. History • Praat keeps track of what you do by hand • If you want to do something, but you’re not sure of the syntax, do : • in script window: Edit | Clear history • in objects window, select the object you want to work on and perform the operation. (Query | Get duration) • in script window(Edit | Paste history)

  19. Open the script: Starter4.praat

  20. Loops • Allow the same commands and functions to be executed over and over again (on a list of files, for example) • Created with:for, endforrepeat, until(and other pairs of commands)

  21. Bug tracking • Error messages can be transparent… • But often are not! • Practice fixing errors by introducing them: – missing $, misspelled/wrong case variable, hard return in form, … • Use print command to print information to info window and find bugs. E.g.: • print got here 'newline$’ • print ‘baseFile’ 'newline$’ • Make changes and test incrementally • Save a backup script that works

  22. Be (very!) careful… • … not to overwrite or delete important files! • Scripts are powerful and one mistake can wipe out days (weeks, months…) of work in seconds • Keep backups of data • When writing/adapting a new script, work in a temporary directory

  23. Acknowledgments • Slides on element types based on Praat scripting tutorial basics, Florian Jaeger http://www.stanford.edu/~tiflo/teaching/tutorials/T_Jaeger_042104-praat%20scripting.htm#slide0001.htm

  24. My new lab (as of October 1, 2008)Laboratoire Parole et LangageAix-en-Provence, France • My e-mail address will be:pauline.welby@lpl-aix.fr

More Related