Basic and advanced Praat Scripting

Slides:



Advertisements
Similar presentations
Copyright © 2012 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin TECHNOLOGY PLUG-IN T2 BASIC SKILLS USING EXCEL.
Advertisements

P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
PL/SQL.
Objectives 1.Identify the functions of a spreadsheet 2.Identify how spreadsheets can be used. 3.Explain the difference in columns and rows. 4.Locate specific.
Tools for Speech Analysis Julia Hirschberg CS4995/6998 Thanks to Jean-Philippe Goldman, Fadi Biadsy.
Tools for Speech Analysis Julia Hirschberg CS4995/6998 Thanks to Jean-Philippe Goldman, Fadi Biadsy.
AN INTRODUCTION TO PRAAT Tina John M.A. Institute of Phonetics and digital Speech Processing - University Kiel Institute of Phonetics and Speech Processing.
Automating Tasks With Macros
Tools for Speech Analysis Julia Hirschberg CS4706 Thanks to Jean-Philippe Goldman, Fadi Biadsy.
Microsoft Office Illustrated Brief File Management Understanding.
Tools for Speech Analysis 2 How do we choose? What kind of data? Which task?
EGR 106 – Week 2 – Arrays & Scripts Brief review of last week Arrays: – Concept – Construction – Addressing Scripts and the editor Audio arrays Textbook.
Guide To UNIX Using Linux Third Edition
Create a Narrated Story with PowerPoint. Basics Enter Text. (Click in the text box and start typing. If a text box is not visible, go to Insert > Text.
SPSS 1: An Introduction to the Statistical Package SPSS Suzie Cro MRC Clinical Trials Unit.
Adding Automated Functionality to Office Applications.
FIRST COURSE Excel Lecture. XP 2 Introducing Excel Microsoft Office Excel 2007 (or Excel) is a computer program used to enter, analyze, and present quantitative.
BoardMaker Ver 6 Creating Interactive Activities for the Classroom.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
Microsoft Office 2007: Introductory 1 Word Lesson 6 Working with Graphics Computer Applications 1.
Laboratory Exercise # 3 – Basic File Management Office Productivity Tools 1 Laboratory Exercise # 3 Basic File Management Objectives: At the end of the.
Computer Programming for Biologists Class 2 Oct 31 st, 2014 Karsten Hokamp
Chapter Seven Advanced Shell Programming. 2 Lesson A Developing a Fully Featured Program.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Programming Logic Program Design. Objectives Steps in program development Algorithms and Pseudocode Data Activity: Alice program.
CTS130 Spreadsheet Lesson 3 Using Editing and Formatting Tools.
European Computer Driving Licence Syllabus version 5.0 Module 4 – Spreadsheets Chapter 22 – Functions Pass ECDL5 for Office 2007 Module 4 Spreadsheets.
JavaScript, Fourth Edition
Lesson No:9 MS-Word Tools, Mail Merge and working with Tables CHBT-01 Basic Micro process & Computer Operation.
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
Introduction to Unix (CA263) File Processing. Guide to UNIX Using Linux, Third Edition 2 Objectives Explain UNIX and Linux file processing Use basic file.
Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that contains an ordered series of commands.
Shell Scripting Introduction. Agenda What is Shell Scripting? Why use Shell Scripting? Writing and Running a Shell Script Basic Commands -ECHO - REM.
1 2 Lab 2: Organizing Your Work. 2 Competencies 3 After completing this lab, you will know how to: 1. Use Explorer to manage files. 2. Copy files. 3.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
XP 1 Microsoft Word 2002 Tutorial 1 – Creating a Document.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Copyright © 2010 Wolters Kluwer Health | Lippincott Williams & Wilkins Introduction to Windows Chapter 2.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin TECHNOLOGY PLUG-IN T2 BASIC SKILLS USING EXCEL.
Speech analysis with Praat Paul Trilsbeek DoBeS training course June 2007.
Specview Tutorial for the Line Identification Tool I. Busko Space Telescope Science Institute March, 2010.
WHAT IS A DATABASE? A DATABASE IS A COLLECTION OF DATA RELATED TO A PARTICULAR TOPIC OR PURPOSE OR TO PUT IT SIMPLY A GENERAL PURPOSE CONTAINER FOR STORING.
FIX Eye FIX Eye Getting started: The guide EPAM Systems B2BITS.
Guide to Oracle 10g ITBIS373 Database Development Lecture 4a - Chapter 4: Using SQL Queries to Insert, Update, Delete, and View Data.
Praat LING115 November 4, Getting started Basic phonetic analyses with Praat –Creating sound objects Recording, reading from a file, creating from.
McGraw-Hill Technology Education © 2004 by the McGraw-Hill Companies, Inc. All rights reserved. Office Access 2003 Lab 2 Modifying a Table and Creating.
Chapter Three The UNIX Editors.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Working with Data Lists.
Editing Basics Lesson 8. Skills Matrix SKILL #MATRIX SKILL 2.2.1Cut, copy, and paste text 2.2.2Find and replace text 4.1.1Insert building blocks in documents.
Trinity College Dublin, The University of Dublin GE3M25: Computer Programming for Biologists Python Karsten Hokamp, PhD Genetics TCD, 03/11/2015.
Chapter 1 Getting Started with Adobe Photoshop CS4.
Linux+ Guide to Linux Certification, Second Edition
Chapter 10: Working with Large Data Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
An electronic document that stores various types of data.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Linux Administration Working with the BASH Shell.
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Excel 2002 Using Macros Lesson.
Praat: doing phonetics by computer Introductory tutorial Kyuchul Yoon Division of English Kyungnam University.
Lesson 5-Exploring Utilities
An Introduction to Computers and Visual Basic
BASIC SKILLS USING EXCEL
Vi Editor.
An Introduction to Computers and Visual Basic
WEB PROGRAMMING JavaScript.
An Introduction to Computers and Visual Basic
Displaying and Editing Data
Tools for Speech Analysis
Presentation transcript:

Basic and advanced Praat Scripting Kyuchul Yoon Division of English Kyungnam University Seoul National University, Linguistics Department, 2006. 12.09

Praat Scripting Language Where to Get Help A Brief Look at a Sample Script Basic Topics Advanced Topics Hands-on Activities Scripting Examples

Where to Get Help Built-in manual “Help” menu of Praat (“search” button) Official Praat homepage www.praat.org Discussion group http://uk.groups.yahoo.com/group/praat-users/ Scripts from other people “Files” menu from the discussion group http://ling.osu.edu/~kyoon/scripts/praat/ http://ling.osu.edu/~welby/praat.html

A Brief Look at a Sample Script

Basic Topics Looks of Praat What Praat can do What is an object? (.TextGrid) How to run a script (example) Language elements Comments, continuation lines, white space Variables, arrays, formulas Jumps, loops

Basic Topics: Looks of Praat Windows: Praat objects, Praat picture, Editor Menus: Praat, New, Read, Write Command buttons (context-sensitive) Activated when an object is selected Changes depending on the type of an object (e.g. Sound) …Help, Edit, Play, Draw…, Query-, Modify-, Annotate- Analyse: Periodicity-, Spectrum-, Formants & LPC-, …, To Intensity… Manipulate: To Manipulation… Synthesize: Convert-, Filter-, Combine sounds- Command buttons (fixed) Rename…, Copy…, Info, Remove, Inspect

Basic Topics: What Praat can do General functions Sound recording Analyses (spectral, pitch, formant, intensity) Annotation Manipulation (pitch, duration, intensity, formant) Specialized functions Voice analysis (jitter, shimmer, noise) Listening experiments Filtering Synthesis (source-filter, articulatory) Learning (neural networks, OT learning) Statistics (multi-dimensional scaling, etc.)

Basic Topics: What is an object? (.TextGrid) A segment of computer memory Contains a set of data in the Praat program Resides in the Praat object window (e.g. sample.wav) e.g.) Sound sample Is NOT a file! (Must be saved!) Needs to be clicked to be selected (Shift, Ctrl, dragging) Types of objects Sound, Spectrum, Spectrogram, TextGrid, Pitch, Formant, Intensity, Manipulation

Basic Topics: What is an object? (.TextGrid) TextGrid object Created with a sound object selected Annotate- To TextGrid… Used for annotation (segmentation and labeling) Consists of a number of tiers Two kinds of tiers: Interval tier: a connected sequence of labeled intervals with boundaries in between Point tier: a sequence of labeled points

Basic Topics: What is an object? (.TextGrid) Examining an object through Query… Gives you information about the selected object Information is displayed by default in the Info window Query results can be used to put information into a variable myStartTime = Get start time myPointLabel$ = Get label of point… 1 1 Modifying an object through Modify… Query results can be used to modify an object, e.g. TextGrid Set point text… 1 1 ‘myPointLabel$’

Basic Topics: How to run a script (example) What is a script? An executable text with menu commands and action commands Praat ==> New/Open Praat script In the script editor, Run ==> Run Edit ==> Paste history in the script editor Records all the menu/action commands Can be used to copy/paste recorded commands Constants could be replaced with variables Clear history to erase all the earlier commands A good source for beginners!

Basic Topics: How to run a script (example) Paste history Read from file... D:\recording\2syllAP-LHa.wav To TextGrid... "phonological phonetic" phonetic plus Sound 2syllAP-LHa Edit select TextGrid 2syllAP-LHa Insert boundary... 1 0.5 Set interval text... 1 1 test ================================================================= fileLocation$ = "D:\recording\2syllAP-LHa.wav" uTonesTierName$ = "phonological" sTonesTierName$ = "phonetic" uTonesTier = 1 intervalText$ = "test" Read from file... 'fileLocation$' Rename… soundObj To TextGrid... "'uTonesTierName$' 'sTonesTierName$'" 'sTonesTierName$' Rename… textgridObj plus Sound soundObj pause Insert a sample interval? select TextGrid textgridObj Insert boundary... uTonesTier 0.5 Set interval text... uTonesTier 1 'intervalText$' Now a script!

Basic Topics: Language elements Comments, continuation lines, white space All white spaces (and tabs) at line beginnings are ignored You can use indenting to make your script readable (tabs preferred) sum = 0 for i to 10 for j to 10 sum = sum + i*j endfor endfor pause The total sum is ‘sum’ Comments lines start with # or ! or ; (# preferred) You can split long command lines into multiple lines using … myStringVariable$ = left$(myMainSentence$, (lengthOfUtterance- …lengthOfRightWord))

Basic Topics: Language elements Variables, arrays, formulas Numeric variables, variable = formula e.g.) lengthOfSentence = 10 String variables (end in a dollar sign), variable$ = string e.g.) sentenceToProcess$ = “Praat rules” Predefined string variables: newline$, tab$, shellDirectory$ Variable substitution (in between single quotes), ‘variable$’ e.g.) echo The number of characters is ‘lengthOfSentence’ e.g.) Try ‘lengthOfSentence:2’ Array variables: simulated with quote substitution e.g.) for j from 1 to 5 square‘j’ = j*j endfor square1 = 1, square2 = 4, square3 = 9, square4 = 16, square5 = 25

Basic Topics: Language elements Jumps, loops for/endfor ################################################# throws = 0 repeat sum = randomInteger(1,6) + randomInteger(1,6) throws = throws + 1 until sum = 12 echo Took me ‘throws’ trials ################################################# throws = 1 sum = randomInteger(1,6) + randomInteger(1,6) while sum <> 12 throws = throws + 1 sum = randomInteger(1,6) + randomInteger(1,6) endwhile echo Took me ‘throws’ trials

Advanced Topics Arguments to commands/scripts Object selection Calling system commands Info window, user interaction, file handling Scripting in an editor window

Advanced Topics Arguments to commands/scripts form/endform keywords form Types of script arguments natural numOfSentences_(positive_whole_number) 337 integer amplitudeSteps_(whole_number) -2000 real factorOfZoomOut_(real_number) -3.5 positive factorOfZoomIn_(positive_real_number) 4.7 comment A line with any text word targetWord_(string_without_spaces) school sentence targetSentence_(any_short_string) my school text targetText_(variableName_not_shown) my school bus boolean trueOrFalse_(with_a_checkbox) 1 choice myChoice_(with_a_radiobox) 1 button choice 1 button choice 2 button choice 3 comment Choose any color optionmenu Color: 2 option Red option Green endform

Advanced Topics Object selection How to select objects from your script select Sound hello1 plus Sound hello2 minus Sound hello2 select all minus Sound hello2 Rename… greeting1 Remove ################## fullFileName$ = “male02-Seoul-32yrs.wav” Read from file… ‘fullFileName$’ filePrefix$ = fullFileName$ - “.wav” newTextGridName$ = filePrefix$ + “.TextGrid”

Advanced Topics Calling system commands Call system (DOS/Unix/Linux) commands from a script directoryName$ = “resultFolder” system_nocheck mkdir ‘directoryName$’ will create a new subfolder in the current folder

Advanced Topics Info window, user interaction, files Writing to the Info window from a script… echo text, clearinfo, print text, printtab, printline text A sample script clearinfo printline Minimum Maximum minValue = 1 maxValue = 10 print ‘minValue’ printtab print ‘maxValue’

Advanced Topics Info window, user interaction, files Messages to the user exit text : to stop the execution of the script with the text message nowarn Write to WAV file… hello.wav : prevents warning messages, e.g. about clipped sound samples noprogress To Pitch… 0 75 500 : prevents from showing a progress window nocheck Remove : causes the script to continue even if there’s nothing to remove pause text : temporarily halts a Praat script. Continue & Stop buttons. Can be used to accept user actions which will be stored in variables e.g.) User selecting a particular section of a sound object in an editor startOfSelection = Get start of selection endOfSelection = Get end of selection

Advanced Topics Info window, user interaction, files File handling Reading an existing file, e.g. hello.wav, sentences.txt Read from file… C:/sound/hello.wav Read Strings from raw text file… C:/text/sentences.txt Creating a new text file in the current folder, e.g. result.txt fileappend result.txt Hello world!’newline$’ fileappend result.txt I am back! Deleting an existing file filedelete C:/sound/hello.wav Getting a list of file names of a particular folder Create Strings as file list… fileListObj C:/sound/*.wav The object fileListObj has a list of filename strings in one column With for/endfor, repeated actions can be taken

Advanced Topics Scripting in an editor window In a Praat script editor/endeditor required In an editor script Only endeditor is required editor Sound soundObj #do your stuff here cursorPosition = Get cursor Select... cursorPosition-0.02 cursorPosition+0.02 Extract sound selection (time from 0) endeditor To Spectrum (fft) Edit

Hands-on Activities Write a script that will help measure the duration of a user-selected segment for all of the .wav files in a folder Keywords to use: form/endform Create Strings as file list… for/endfor Edit pause fileappend

Hands-on Activities # Put variables here form Parameter settings word inFolder_(with_sounds) demo-folder word outFile_(to_be_created) measurements.txt endform # Make a list of files in the folder Create Strings as file list... fileListObj ‘inFolder$’/*.wav Sort numOfFiles = Get number of strings pause ‘numOfFiles’ files identified. Continue? # Loop through each file for iFile to numOfFiles select Strings fileListObj fileName$ = Get string... iFile pause Opening the file ‘fileName$’ Read from file... ‘inFolder$’/’fileName$’ Rename... soundObj Edit editor Sound soundObj pause Select the target segment targetDuration = Get selection length endeditor Remove fileappend ‘outFile$’ ‘fileName$’‘tab$’‘targetDuration:2’‘newline$’ endfor Remove all # End of script

Scripting Examples Scripts for (1) Prosody swapping (2) Speech corpus searching (3) K-ToBI labeling