# AverInt.praat # # Script for PRAAT 5.1 (www.praat.org) # # This script takes a group of matching files, and computes the average # intensity of these files, using only the speech portions and ignoring the # silent portions of these files. # This Praat script was written for the thesis work of Lisette van Delft. # # (c) 2009 Hugo Quené, Utrecht University [H.Quene@uu.nl] # HQ 20090324 initial release folder$ = "/Users/Hugo/rhythm/Lisette_van_Delft" minpitch = 80 printline -- # ask for file specification form File specifications # working directory for read and write, last char is slash # comment Enter folder where audio wave files are stored: # sentence Folder Users/Hugo/rhythm/Lisette_van_Delft/ comment Enter pattern for file specification (wildcards allowed): sentence Pattern i_*.wav comment Enter minimum pitch: positive Minpitch_(Hz) 80 endform sumint = 0 # longpattern$ = 'folder$'+"/"+'pattern$' Create Strings as file list... fileList 'folder$'/'pattern$' nfiles = Get number of strings list = selected("Strings") for i from 1 to 'nfiles' select 'list' fn$ = Get string... 'i' # pause Next file is 'fn$' Read from file... 'folder$'/'fn$' fid = selected("Sound") # do things with this file printline Processing file 'folder$'/'fn$' filedur = Get total duration To TextGrid (silences)... 80 0 -25 0.1 0.075 silent speech tid = selected("TextGrid") plus 'fid' Extract intervals where... 1 no "is equal to" speech # all speech intervals are in separate objects, all are selected # from Praat manual aux = numberOfSelected("Sound") for j to aux sound'j' = selected("Sound",j) endfor Concatenate # result is Sound object named "chain" chainid = selected("Sound") To Intensity... 'minpitch' 0 yes iid = selected("Intensity") speechdur = Get total duration speechint = Get mean... 0 0 dB printline intensity 'speechint:1' dB (over 'speechdur:3'/'filedur:3' s) # sum and mean are not weighted for duration sumint = 'sumint' + 'speechint' # cleanup select 'fid' plus 'tid' plus 'iid' plus 'chainid' Remove # from Praat manual if aux>=1 select sound1 for j from 2 to aux plus sound'j' endfor # remove intermediate speech portions Remove endif endfor # not weighted for duration averint = 'sumint' / 'nfiles' printline Average intensity is 'averint:1' dB over speech portions in 'nfiles' files matching "'pattern$'" # cleanup select 'list' Remove