1

I have a TextGrid file with 2 tiers, one corresponds to words and another one to syllables. I already creating a column of syllables in my table and now I need to make a column with words where each syllable should correspond to the word it belongs to. So the result should look like:

e.g. This is my sentence.

This 
is
my
sentence 
sentence

(I can try to explain it more thoroughly, if it is not clear.)

This is what I have so far. It works, but needs some modification.

writeInfo: ""

selectObject: "TextGrid example"
num = Get number of intervals: 2 #for the syllable tier
number = Get number of intervals: 1 #for the word tier


for m from 1 to num
    ends = Get end time of interval: 2, m
    for n from 1 to number
        word$ = Get label of interval: 1, n
        endw = Get end time of interval: 1, n
        if ends == endw
            appendInfoLine: word$
        endif

    endfor
endfor
4

1 回答 1

3

这应该有效。它遍历每个音节并获取单词层上相应间隔的标签。它假定没有空区间。如果您需要做进一步的分析,您可以使用writeFileappenFileLine写入文件而不是信息窗口。

writeInfo: ""

selectObject: "TextGrid example"
num = Get number of intervals: 2 #for the syllable tier

for m from 1 to num
    syllable$ = Get label of interval: 2, m
    syllable_start = Get start time of interval: 2, m
    word = Get interval at time: 1, syllable_start
    word$ = Get label of interval: 1, word
    appendInfoLine: "'word$','syllable$'"
endfor
于 2018-01-06T21:32:53.997 回答