1

I'm new here. Just found that there is a linguistics community on stack exchange!

I have a TextGrid file that has been output from a forced aligner, webMAUS and I mainly want to understand how to extract specific data from it using a python script and input into a csv file, but I'm not sure how to go about it. I need to be able to run this for large amounts of data.

The data I want to extract is: the duration of the sentence, which is in the first item tier, the duration of the compound "trial offer" and the duration of the phonemes within the compound, 'trial offer' which is found in the last tier. Is there any way to do this? Thank you.

Here is the text grid:

File type = "ooTextFile"
Object class = "TextGrid"

xmin = 0 
xmax = 4.360703
tiers? <exists> 
size = 3
item []:
    item [1]:
        class = "IntervalTier"
        name = "ORT-MAU"
        xmin = 0
        xmax = 4.360703
        intervals: size = 9
        intervals [1]:
            xmin = 0.000000
            xmax = 1.380000
            text = ""
        intervals [2]:
            xmin = 1.380000
            xmax = 1.570000
            text = "She"
        intervals [3]:
            xmin = 1.570000
            xmax = 1.800000
            text = "told"
        intervals [4]:
            xmin = 1.800000
            xmax = 1.920000
            text = "me"
        intervals [5]:
            xmin = 1.920000
            xmax = 2.150000
            text = "about"
        intervals [6]:
            xmin = 2.150000
            xmax = 2.230000
            text = "the"
        intervals [7]:
            xmin = 2.230000
            xmax = 2.700000
            text = "trial"
        intervals [8]:
            xmin = 2.700000
            xmax = 3.010000
            text = "offer"
        intervals [9]:
            xmin = 3.010000
            xmax = 4.360703
            text = ""
    item [2]:
        class = "IntervalTier"
        name = "KAN-MAU"
        xmin = 0
        xmax = 4.360703
        intervals: size = 9
        intervals [1]:
            xmin = 0.000000
            xmax = 1.380000
            text = ""
        intervals [2]:
            xmin = 1.380000
            xmax = 1.570000
            text = "S i:"
        intervals [3]:
            xmin = 1.570000
            xmax = 1.800000
            text = "t @U l d"
        intervals [4]:
            xmin = 1.800000
            xmax = 1.920000
            text = "m i:"
        intervals [5]:
            xmin = 1.920000
            xmax = 2.150000
            text = "@ b aU t"
        intervals [6]:
            xmin = 2.150000
            xmax = 2.230000
            text = "D @"
        intervals [7]:
            xmin = 2.230000
            xmax = 2.700000
            text = "t r aI @ l"
        intervals [8]:
            xmin = 2.700000
            xmax = 3.010000
            text = "Q f @"
        intervals [9]:
            xmin = 3.010000
            xmax = 4.360703
            text = ""
    item [3]:
        class = "IntervalTier"
        name = "MAU"
        xmin = 0
        xmax = 4.360703
        intervals: size = 23
        intervals [1]:
            xmin = 0.000000
            xmax = 1.380000
            text = "<p:>"
        intervals [2]:
            xmin = 1.380000
            xmax = 1.490000
            text = "S"
        intervals [3]:
            xmin = 1.490000
            xmax = 1.570000
            text = "I"
        intervals [4]:
            xmin = 1.570000
            xmax = 1.700000
            text = "t"
        intervals [5]:
            xmin = 1.700000
            xmax = 1.740000
            text = "@U"
        intervals [6]:
            xmin = 1.740000
            xmax = 1.800000
            text = "l"
        intervals [7]:
            xmin = 1.800000
            xmax = 1.860000
            text = "m"
        intervals [8]:
            xmin = 1.860000
            xmax = 1.920000
            text = "I"
        intervals [9]:
            xmin = 1.920000
            xmax = 1.960000
            text = "@"
        intervals [10]:
            xmin = 1.960000
            xmax = 2.010000
            text = "b"
        intervals [11]:
            xmin = 2.010000
            xmax = 2.120000
            text = "aU"
        intervals [12]:
            xmin = 2.120000
            xmax = 2.150000
            text = "t"
        intervals [13]:
            xmin = 2.150000
            xmax = 2.180000
            text = "D"
        intervals [14]:
            xmin = 2.180000
            xmax = 2.230000
            text = "@"
        intervals [15]:
            xmin = 2.230000
            xmax = 2.370000
            text = "t"
        intervals [16]:
            xmin = 2.370000
            xmax = 2.430000
            text = "r"
        intervals [17]:
            xmin = 2.430000
            xmax = 2.580000
            text = "aI"
        intervals [18]:
            xmin = 2.580000
            xmax = 2.610000
            text = "@"
        intervals [19]:
            xmin = 2.610000
            xmax = 2.700000
            text = "l"
        intervals [20]:
            xmin = 2.700000
            xmax = 2.820000
            text = "Q"
        intervals [21]:
            xmin = 2.820000
            xmax = 2.920000
            text = "f"
        intervals [22]:
            xmin = 2.920000
            xmax = 3.010000
            text = "@"
        intervals [23]:
            xmin = 3.010000
            xmax = 4.360703
            text = "<p:>"

2 Answers 2

1

Xmin and xmax are the starting times in seconds, within the file (which goes from 0 to 4.360703 seconds), and ORT-MAU tells you the same thing (in this instance), but then tells you the time periods of the individual words (where xmax-xmin is the duration of the word). So you would be interested in the texts “trial” and “offer” (not necessarily intervals [7] and [8] in the first tier). KAN-MAU is the same information except with a quasi-phonetic transliteration. Finally, MAU seems to be a quasi-phonemic parsing of the words, so for instance the “i” of “trial” is intervals [17] within item [3] which is named MAU, and the duration of that phoneme is 2.580000-2.430000 seconds. So you just read the stream looking for the three tiers and the intervals of interest. Presumably by “sentence” you mean “that part of the sound file which the program interpreted as being speech”, so you exclude the initial and final non-text margins. Since the phonetic content of “trial offer” may vary from token to token, you would especially want to keep track of the interval corresponding to the spelling “trial offer” (just in case the section of interest is not always final in the file).

1

I don't know how homogenous is TextGrid across different tools that use it, but there is a Python package, pympi which can be used to read Praat TextGrid files.

In particular, pympi.Praat.TextGrid class can be instantiated to read TextGrid files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.