# This script has been created by Paolo Mairano (University of Warwick) # It takes Sound and TextGrid files as input, the TextGrids must be annotated with 1 interval tier # It will output truncated wav files for each interval # The original interval label will be the name of each truncated file clearinfo select all # form con il nome dei file che conterranno i risultati form Dir acquisition comment !!! WARNING, THIS IS BETA SOFTWARE !!! comment Enter full path to data text Directory /home/valentina/Scrivania/gizzeria/ boolean normalize 1 real start_offset 0.000 real end_offset 0.000 comment Leave Base_file blank to analyze all files word Base_file_name endform # Read all textgrids in a folder Create Strings as file list... wavlist 'directory$'/'base_file_name$'*.wav Create Strings as file list... textgridlist 'directory$'/'base_file_name$'*.TextGrid n = Get number of strings # loops through files for f to n # reads wav and creates sound object select Strings wavlist filename$ = Get string... f Read from file... 'directory$'/'filename$' soundname$ = selected$ ("Sound") printline Analyzing 'soundname$'... # read textgrid select Strings textgridlist textgridname$ = Get string... f Read from file... 'directory$'/'textgridname$' int = Get number of intervals... 1 # get values for each interval for i to 'int' word$ = Get label of interval... 1 i xmin = Get starting point... 1 i xmax = Get end point... 1 i xmin = xmin - start_offset xmax = xmax + end_offset if word$ <> "" and index (word$, "*") == 0 select Sound 'soundname$' Extract part... 'xmin' 'xmax' rectangular 1 no select Sound 'soundname$'_part if normalize = 1 Scale intensity... 70.0 endif createDirectory(soundname$) Save as WAV file... 'soundname$'/'word$'.wav Remove select TextGrid 'soundname$' endif endfor select Sound 'soundname$' Remove select TextGrid 'soundname$' Remove endfor printline ############################ printline Completed. printline ############################