praat

Praat scripting: How to get rid of "_" in accent tier and it's corresponding syllables in Info Window?


I have a point tier that shows accents. I also have a syllable tier. I need to extract the labels of the syllable tier with the corresponding accents. The only thing that I don't need is the extracting of the label "_" and "%" in the accent tier.

My code so far:

writeInfo: ""

selectObject: "TextGrid example"

number = Get number of points: 2 #for the accent tier
for n from 1 to number
accent_time = Get time of point: 2, n
syllable = Get interval at time: 1, accent_time #for the syllable tier
syllable$ = Get label of interval: 1, syllable
accent$ = Get label of point: 2, n
    #if accent$ = "_" and "%"
    #don't append syllable
    #endif
appendInfoLine: syllable$, "       ",accent$
endfor

Result:

"Ra:n       H*L
"tOm       H*
gRam       L*H
"tROts       -
"tROts       H*L
"u:       H*L
"tsjo:n       -
"fEst       H*L

What I'm aiming to get:

"Ra:n       H*L
"tOm       H*
gRam       L*H
"tROts       H*L
"u:       H*L
"fEst       H*L

Solution

  • writeInfo: ""
    
    selectObject: "TextGrid example"
    
    number = Get number of points: 2 #for the accent tier
    for n from 1 to number
    accent_time = Get time of point: 2, n
    syllable = Get interval at time: 1, accent_time #for the syllable tier
    syllable$ = Get label of interval: 1, syllable
    accent$ = Get label of point: 2, n
        if accent$ <> "_" and accent$ <> "%"
            appendInfoLine: syllable$, "       ",accent$
        endif
    endfor