# Create textgrids with points and labels according to # file names, timepoints, and labels in tab-separated text file # # Put the name of the sound file in the first column (minus .wav), # put the timepoint in the second column, # and put the label in the third column # **Table must have header row, although names are irrelevant** # # ***Make sure you don't have any spaces in your file paths*** # (i.e. don't use folders with spaces in the name, # and make sure there are no extra spaces at the end) # # Author: Danielle Daidone 11/16/24 #################################################### form Add points and labels to tier from table comment Give the directory of the sound files: comment (TextGrids will be created and saved here as well) sentence soundDir C:\Users\Danielle\Desktop\ForDanielle\ comment Give the path and name of the tab-separated input text file: word inputTable C:\Users\Danielle\Desktop\ForDanielle\InputTable.txt endform # remove any objects open in object window select all numberOfSelectedObjects = numberOfSelected () if numberOfSelectedObjects > 0 Remove endif # write header in info window writeInfoLine: "File'tab$'Point'tab$'Label" # read in table; first row will be treated as headers Read Table from tab-separated file... 'inputTable$' Rename... table select Table table # get number of rows in table numRows = Get number of rows for i to numRows # get name of sound file and cursor point filename$ = Table_table$ [i, 1] cursor$ = Table_table$ [i, 2] cursorPt = number(cursor$) label$ = Table_table$ [i, 3] # check if textgrid already exists nocheck selectObject: "TextGrid 'filename$'" if numberOfSelected ("TextGrid") > 0 # if textgrid exists, insert point at value from table Insert point... 1 cursorPt 'label$' Write to text file... 'soundDir$''filename$'.TextGrid appendInfoLine: "'filename$''tab$''cursor$''tab$''label$'" else # if not, open sound file and create textgrid Read from file... 'soundDir$''filename$'.wav To TextGrid... points points # now insert point at value from table Insert point... 1 cursorPt 'label$' Write to text file... 'soundDir$''filename$'.TextGrid appendInfoLine: "'filename$''tab$''cursor$''tab$''label$'" endif endfor #clear the Objects window select all Remove appendInfoLine: "Finished! TextGrids successfully saved."