Search code examples
phoneticspraat

Praat script to remove specific boundaries


I'm wondering if there is any Praat script available that removes boundaries between two specific segments in a specific Tier.

For example, if Tier1 contains a word such as cars, and Tier2 contains the corresponding segments |k|ɑː|r|z|. How can I remove the boundary between, say, r|z in all TextGrid files in the respective directory?

Thank you in advance!


Solution

  • welcome to SO. It would be easier to help if you gave us an example of what you have been working on, and why it is currently not working.

    Does every TextGrid only contain one word? If so, add this to the script that loops through the files. I got this to work on a toy example, but a problem will arise if there are an unknown number of words that contain the combination, because you will be changing the number of boundaries that you are looping through and eventually try and read an interval that no longer exists.

    # Check all intervals in segment tier:
            for i from 1 to numberOfIntervals-1
                label$ = Get label of interval... segment_tier 'i'
                if label$ = "z"
                    previous_label$ = Get label of interval... segment_tier 'i'-1
                    if previous_label$ = "r"
                        selection_start = Get start point: segment_tier, 'i'
                        Remove boundary at time: segment_tier, selection_start
                        numberOfIntervals = numberOfIntervals-1
                    endif
    
                    # select the TextGrid so we can iterate to the next interval:
                    select TextGrid 'soundname$'
                endif
            endfor
    

    You will also need to save the TextGrid before looping to the next one:

            select TextGrid 'soundname$'
            Save as text file... 'textGrid_directory$''soundname$'.TextGrid
            Remove