## This script extracts and plays marked vowels of the selected type in files from a selected decade.
## Vowels must be manually marked, and decade is deduced from the file name.
## Vowels can be extracted either in isolation or in the context of a target word.
## The script is designed to qualitatively assess vowel differences that are measured. With the use of the script, 
## a large quantity of vowels can be browsed relatively quickly.
##
## The script is written by jthoegersen@hum.ku.dk, GNU/GPL
##

form Vowel Extractor
choice Vowel 1
    button e
    button æ
    button ANLong
    button ANShort
    button AMShort
    button AMLong
    button C
    button O
    button å
    button ræ
    button ru
    button Aj
    button oj

choice Target 1
    button 1950s
    button 1960s
    button 1970s
    button 1980s
    button 1990s
    button 2000s

choice Context 2
    button In isolation
    button In target word
endform

Create Strings as file list... files L:\Korpus\vokaler\final\*.TextGrid

select Strings files
strings = Get number of strings

for string to strings

    select Strings files

    string$ = Get string... string
    filename$ = replace$ ("'string$'", ".TextGrid", "", 1)

    ### Select files ###
    variable$ = replace_regex$ ("'filename$'", "([0-9]+_)?([0-9]_)?[0-9]{8}_", "", 1)
    variable$ = replace_regex$ ("'variable$'", "_?F", "", 1)

    if variable$ = vowel$
        
        file$ = replace_regex$ ("'filename$'", "_'variable$'_?F", "", 1)
        file2$ = replace_regex$ ("'file$'", "^([0-9]+_)?([0-9]_)?([0-9]_)*", "", 1)
        year$ = replace_regex$ ("'file2$'", "[0-9]{4}$", "", 1)
        decade$ = replace_regex$ ("'year$'", "[0-9]$", "0", 1)
        decade$ = "'decade$'s"

        if decade$ = target$

            Open long sound file... L:\Korpus\lydfiler\'file$'.wav
            Read from file... L:\Korpus\vokaler\final\'string$'
    
            hits = Get number of intervals... 3

            for hit to hits

                select TextGrid 'filename$'

                label$ = Get label of interval... 3 hit

                if label$ <> ""

                    start = Get start point... 3 hit
                    end = Get end point... 3 hit
                    mid = start+((end-start)/2)

                    if context$ = "In target word"
                        ortointerval = Get interval at time... 1 mid
                        start = Get start point... 1 ortointerval
                        end = Get end point... 1 ortointerval
                        end = end+0.01
                    endif
    
                    select LongSound 'file$'

                    Extract part... start-0.01 end+0.01 no
                    Play
                    Remove

                    beginPause ("Continue?")
                    loop = endPause("Continue", "Next file", "Abort", 1)

                    if loop = 2
                        hit = hits
                    endif

                    if loop = 3
                        hit = hits
                        string = strings
                    endif
                endif
            endfor

            select LongSound 'file$'
            Remove
            select TextGrid 'filename$'
            Remove
        endif
    endif
endfor

select Strings files
Remove

Addition to the Great Formant Extraction Script – checks for “Stød”

clearinfo

files = Get number of strings

for file to files

    select Strings appended

    string$ = Get string... file

    Read from file... L:\Korpus\vokaler\'string$'

    vowels = Get number of points... 4

    for vowel to vowels

        time = Get time of point... 4 vowel

        ortointerval = Get interval at time... 1 time
        word$ = Get label of interval... 1 ortointerval
        phon$ = Get label of interval... 2 ortointerval

        if index (string$, "Long") > 0    
            
            if index (string$, "AN") > 0

                if index (phon$, "z:!") > 0

                    stod$ = "!"

                else
                    stod$ = ""
                endif

            elsif index (string$, "AM") > 0

                if index (phon$, "A:!") > 0

                    stod$ = "!"
                else
                    stod$ = ""
                endif
            endif

        elsif index (string$, "Long") = 0
            stod$ = ""
        endif

        printline 'stod$'
    endfor
    Remove
endfor

The Great Formant Extraction Script

### Create new file ###

#if fileReadable ("L:\Korpus\vokaler\statistik\'file$'_'variable$'.csv")
#    deleteFile ("L:\Korpus\vokaler\statistik\'file$'_'variable$'.csv")
#endif

if fileReadable ("L:\Korpus\vokaler\statistik\AllFiles.csv")
    deleteFile ("L:\Korpus\vokaler\statistik\AllFiles.csv")
endif

### Header ###
#fileappend L:\Korpus\vokaler\statistik\'file$'_'variable$'.csv File;Year;Decade;Speaker;Variable;PreWord;TargetWord;ProWord;PreSound;ProSound;Timing;MaxFreq;BW1;BW2;BW3;F1;F2;F3;DefaultFreq;BW1d;BW2d;BW3d;F1d;F2d;F3d'newline$'
fileappend L:\Korpus\vokaler\statistik\AllFiles.csv File;Year;Decade;Speaker;Sex;Variable;PreWord;TargetWord;ProWord;PreSound;ProSound;Timing;MaxFreq;BW1;BW2;BW3;F1;F2;F3;DefaultFreq;BW1d;BW2d;BW3d;F1d;F2d;F3d'newline$'

Create Strings as file list... filesShort L:\Korpus\vokaler\*Short*F.TextGrid
Create Strings as file list... filesLong L:\Korpus\vokaler\*Long*F.TextGrid

plus Strings filesShort
Append

select Strings filesShort
Remove
select Strings filesLong
Remove

Read Strings from raw text file... L:\Korpus\femaleSpeakers.txt
females = Get number of strings

select Strings appended
strings = Get number of strings

for string to strings

    select Strings appended

    string$ = Get string... string
    filename$ = replace$ ("'string$'", ".TextGrid", "", 1)

    ### Select files ###
    variable$ = replace_regex$ ("'filename$'", "([0-9]+_)?([0-9]_)?[0-9]{8}_", "", 1)
    variable$ = replace_regex$ ("'variable$'", "_?F", "", 1)

    file$ = replace_regex$ ("'filename$'", "_'variable$'_?F", "", 1)

    file2$ = replace_regex$ ("'file$'", "^([0-9]+_)?([0-9]_)?([0-9]_)*", "", 1)
    year$ = replace_regex$ ("'file2$'", "[0-9]{4}$", "", 1)

    decade$ = replace_regex$ ("'year$'", "[0-9]$", "0", 1)

    #decade = 'decade$'
    decade$ = "'decade$'s"

    Read from file... L:\Korpus\vokaler\'string$'
    Open long sound file... L:\Korpus\lydfiler\'file$'.wav
    Read from file... L:\Korpus\textgrids\'file$'.TextGrid

    ortointervals = Get number of intervals... 1

    ### Default speaker ###

    speakersegment$ = "XXX"


    ### Loop ###

    select TextGrid 'filename$'

    vowels = Get number of points... 4

    for vowel to vowels

        select TextGrid 'filename$'

        time = Get time of point... 4 vowel

        ### Orthography ###

        ortointerval = Get interval at time... 1 time
        word$ = Get label of interval... 1 ortointerval

        if ortointerval > 1
            preword$ = Get label of interval... 1 ortointerval-1
        else
            preword$ = ""
        endif

        if ortointerval < ortointervals
            proword$ = Get label of interval... 1 ortointerval+1
        else
            proword$ = ""
        endif

        ### Find speaker ###

        select TextGrid 'file$'
        segment = Get interval at time... 2 time
        speaker$ = Get label of interval... 2 segment

        speaker$ = replace_regex$ ("'speaker$'", ".+\(", "", 1)
        speaker$ = replace_regex$ ("'speaker$'", "\)$", "", 1)

        if speaker$ <> speakersegment$

            sex = 1
            
            select Strings femaleSpeakers

            for speaker to females

                taler$ = Get string... speaker

                if startsWith (speaker$, taler$) > 0

                    sex = 2
                endif
            endfor
                    
            if sex = 1
                defaultfreq = 5000
                sex$ = "M"
            elsif sex = 2
                defaultfreq = 5500
                sex$ = "F"
            endif

            speakersegment$ = speaker$

        endif

        ### Vowel timing ###

        select TextGrid 'filename$'
        vowelinterval = Get interval at time... 3 time
        vowelstart = Get start point... 3 vowelinterval
        vowelend = Get end point... 3 vowelinterval
        voweltime = vowelend-vowelstart
        voweltime = voweltime*1000

        ### Phonological context ###

        phoninterval = Get interval at time... 2 time
        phon$ = Get label of interval... 2 phoninterval

        ### Index depends on variable ###

        if variable$ = "ANLong"
            place = index (phon$, "2z:")
        elsif variable$ = "ANShort"
            place = index (phon$, "2a")
        elsif variable$ = "AMLong"
            place = index (phon$, "2A:")
        elsif variable$ = "AMShort"
            place = index (phon$, "2A")
        endif

        ### Preceeding vowel (may be in preceeding interval, if that is not empty) ###

        preceeding$ = mid$ (phon$, place-1, 1)

        if preceeding$ = "["
            phon2$ = Get label of interval... 2 phoninterval-1
    
            if phon2$ = ""
                preceeding$ = "Ø"
            else
                length = length (phon2$)
                preceeding$ = mid$ (phon2$, length-1, 1)
            endif
        endif


        ### Proceeding vowel (may be in proceeding interval, if that is not empty) ###

        if endsWith (variable$, "Long")
    
            proceeding$ = mid$ (phon$, place+3, 1)

            ### If the vowel has stød, the stød is not considered context ###

            if proceeding$ = "!"
                proceeding$ = mid$ (phon$, place+4, 1)
            endif
        
            if proceeding$ = "]"

                phon2$ = Get label of interval... 2 phoninterval+1

                if phon2$ = ""
                    proceeding$ = "Ø"
                else
                    proceeding$ = mid$ (phon2$, 2, 1)

                    if proceeding$ = "2"
                        proceeding$ = mid$ (phon2$, 3, 1)
                    endif
                endif
            endif

        elsif endsWith (variable$, "Short")

            proceeding$ = mid$ (phon$, place+2, 1)

            ### If the vowel has stød, the stød is not considered context ###

            if proceeding$ = "!"
                proceeding$ = mid$ (phon$, place+3, 1)
            endif
        
            if proceeding$ = "]"

                phon2$ = Get label of interval... 2 phoninterval+1

                if phon2$ = ""
                    proceeding$ = "Ø"
                else
                    proceeding$ = mid$ (phon2$, 2, 1)

                    if proceeding$ = "2"
                        proceeding$ = mid$ (phon2$, 3, 1)
                    endif
                endif
            endif
        endif

        ### Formant extraction ###

        select LongSound 'file$'

        Extract part... time-0.1 time+0.1 yes

        maxfreq = 4500
        bw = 1000


        ### Evaluate BandWidth of f1 and select candidate MaxFreq setting ###

        while maxfreq < 6000

            To Formant (burg)... 0 5 maxfreq 0.03 50
            bw1'maxfreq' = Get bandwidth at time... 1 time Hertz Linear
            bw2'maxfreq' = Get bandwidth at time... 2 time Hertz Linear
            bw'maxfreq' = bw1'maxfreq'+bw2'maxfreq'

            if bw'maxfreq' < bw
                bw = bw'maxfreq'
                freq = maxfreq
            endif

            Remove

            maxfreq = maxfreq + 100

            select Sound 'file$'
    
        endwhile

        ### Formant extraction - best candidate ###
    
        To Formant (burg)... 0 5 freq 0.03 50
    
        f1 = Get value at time... 1 time Hertz Linear
        f2 = Get value at time... 2 time Hertz Linear
        f3 = Get value at time... 3 time Hertz Linear
        bw1 = Get bandwidth at time... 1 time Hertz Linear
        bw2 = Get bandwidth at time... 2 time Hertz Linear
        bw3 = Get bandwidth at time... 3 time Hertz Linear
        Remove

        ### Formant extraction - default ###

        select Sound 'file$'

        To Formant (burg)... 0 5 defaultfreq 0.03 50
    
        f1d = Get value at time... 1 time Hertz Linear
        f2d = Get value at time... 2 time Hertz Linear
        f3d = Get value at time... 3 time Hertz Linear
        bw1d = Get bandwidth at time... 1 time Hertz Linear
        bw2d = Get bandwidth at time... 2 time Hertz Linear
        bw3d = Get bandwidth at time... 3 time Hertz Linear
        Remove

        select Sound 'file$'
        Remove

        ### Printout ###

        #fileappend L:\Korpus\vokaler\statistik\'file$'_'variable$'.csv 'file$';'year$';'decade$';'speaker$';'sex';'variable$';'preword$';'word$';'proword$';'preceeding$';'proceeding$';'voweltime:0';'freq';'bw1:0';'bw2:0';'bw3:0';'f1:0';'f2:0';'f3:0';'defaultfreq';'bw1d:0';'bw2d:0';'bw3d:0';'f1d:0';'f2d:0';'f3d:0''newline$'
        fileappend L:\Korpus\vokaler\statistik\AllFiles.csv 'file$';'year$';'decade$';'speaker$';'sex$';'variable$';'preword$';'word$';'proword$';'preceeding$';'proceeding$';'voweltime:0';'freq';'bw1:0';'bw2:0';'bw3:0';'f1:0';'f2:0';'f3:0';'defaultfreq';'bw1d:0';'bw2d:0';'bw3d:0';'f1d:0';'f2d:0';'f3d:0''newline$'

    endfor

    select LongSound 'file$'
    Remove
    select TextGrid 'file$'
    Remove
    select TextGrid 'filename$'
    Remove

endfor

A Praat script to assist manual coding of variables

## This script is used in coding for assimilated endings, but it could be modified to any other task that invoves
## a human evaluation of a sound extract.
##
## The script searches for words ending in certain strings of letters in adjectives and verbs 
## (i.e. words that are coded as of these Parts of Speech). If the string is found, the corresponding
## sound is extracted and played for the coder. When the coder has decided on the proper code, he or she
## enters it, and it is written to the TextGrid. The coder can listen to the extract any number of times,
## and cancel the task if in doubt.
## There is no "undo".
##
## A list of excluded words can be given in the txt file "ExcludedWords.txt"
##
## The script is written December 2011 by jthoegersen@hum.ku.dk and is GNU/GPL
##


# The coder initials are used to generate unique output tier names and output files from each coder

form Coding of assimilations
    comment Search criteria
    word Search_string
    comment Coder initials (in capitals)
    word Coder
endform



filename$ = selected$ ("TextGrid")


# A list of words that are to be omitted from the analysis can be generated as a txt file.

Read Strings from raw text file... C:\tmp\ExcludedWords.txt

Open long sound file... c:\tmp\'filename$'.wav


select TextGrid 'filename$'
tiers = Get number of tiers


# The script checks whether the output tier already exists (as the last tier) to avoid working on files that have already been coded once

lastTier$ = Get tier name... tiers

if lastTier$ = "Assimilation_'coder$'"
    beginPause ("Error!")
    comment ("The output tier already exists. Delete tier?")
    delete = endPause ("Yes", 0)

    if delete = 1
        Remove tier... tiers
    endif
    
endif


# The output tier is (re)generated

Insert interval tier... tiers+1 Assimilation_'coder$'

tiers = Get number of tiers


# "Intervals" are the intervals that are being analysed. Change the tier number if they are not in tier 1 

intervals = Get number of intervals... 1


# "Trials" is a counter of the number of times the coder listens before making a choice (i.e. a certainty check)

trials = 1


# Here is the search procedure proper.

for interval to intervals

    select TextGrid 'filename$'
    label$ = Get label of interval... 1 interval


# Look in the exclusion list for words that are omitted

    exclude = 0

    select Strings ExcludedWords
    strings = Get number of strings

    for string to strings

        string$ = Get string... 'string'

        if label$ = "'string$'"
            exclude = 1
        endif
    endfor


    select TextGrid 'filename$'

    if exclude = 0

        if endsWith (label$, "search_string$")


# "stem" is generated as the entire word minus the ending (the RegEx removes the search string only at the end of the word ($)).

            stem$ = replace_regex$ ("'label$'", "'search_string$'$", "", 1)

            call assimilations

        endif
    endif
endfor

###

# Cleanup after all intervals have been checked

select LongSound 'filename$'
Remove
select Strings ExcludedWords
Remove
select TextGrid 'filename$'
Save as text file... c:\tmp\output\'filename$'_'search_string$'_'coder$'.TextGrid


#################################

procedure assimilations


# Part-of-speech is included as an additional search criteria

pos_label$ = Get label of interval... 5 interval

if index_regex("'pos_label$'", "(ADJ|V_PRES|V_PAST|V_PARTC_PAST)") > 0


# Timecodes for extraction of sound (including a 25 ms buffer) and for the placement of the output interval in the output tier

    start = Get starting point... 1 interval
    end = Get end point... 1 interval
    endCut = 'end'+0.025
    startCut = 'start'-0.025


# The boundaries of the interval of the output tier in which the code is written, is generated. There is a small work-around
# because Praat will not set a boundary at the very beginning of a file (where there is already a default boundary). If one has
# search strings that may appear in the very last interval of the tier, something similar must be written to avoid writing "end"
# boundaries in the last interval.

    stringIntervals = Get number of intervals... tiers

    if stringIntervals > 1

        tEndBoundary = Get end point... tiers stringIntervals-1

        if tEndBoundary <> start
            Insert boundary... tiers start
        endif

    elsif stringIntervals = 1

        Insert boundary... tiers start

    endif

    Insert boundary... tiers end
    
    select LongSound 'filename$'

    Extract part... startCut endCut no
    Play

######

# A pause prompt asks for coder's input. In this case, the coder has to choose between two different orthogrphical forms
# distinguished by the ending, and pronounced as but coders could equally well be asked to hear "assimilated" vs. "non-assimilated", "stop"
## vs. "fricative" etc.
# The "error" button is used if the script proposes a candidate word that shouldn't be analysed. (The script editor should search the
# output tier for "N/A"s and potentially add the words to the "ExcludedWords" list).

    beginPause ("What do you hear?")
    comment ("Is the word 'stem$'et or 'stem$'ede?")
    endelse = endPause("-et", "-ede", "Listen again", "Error!", 3)

    if endelse <> 3

        select TextGrid 'filename$'

        tttInterval = Get interval at time... tiers start


# The output label, of course, has to be adjusted to the individual task. Potentially one could just use "1", "2" and "3".
# The number of listens is also written to the code, and is immediately reset to 1.

        if endelse = 1
            Set interval text... tiers tttInterval \dh'tab$''trials'
            trials = 1
        elsif endelse = 2
            Set interval text... tiers tttInterval \dh\sw'tab$''trials'
            trials = 1
        elsif endelse = 4
            Set interval text... tiers tttInterval N/A'tab$''trials'
            trials = 1
        endif


# If the coder wishes to listen again, 1 is added to the number of listens, boundaries are deleted (they will be written again immediately,
# and the loop is sent back to the same interval once again.
            
    elsif endelse = 3
                
        select TextGrid 'filename$'

        Remove boundary at time... tiers start
        Remove boundary at time... tiers end

        interval = interval - 1

        trials = trials + 1

    endif

    select Sound 'filename$'
    Remove

endif

endproc

A script for manually coding features. The coder inputs boundaries which are written to the TextGrid

## This script is used in coding for assimilations, but could be modified to any other task that invoves
## a human evaluation of a sound extract.
##
## The script searches for words ending in a certain string of letters in adjectives and verbs
## (i.e. words that are not of other Parts of Speech). If the string is found, the corresponding
## sound is played for the coder and the the TextGrid is shown.
## The coder's task is to set boundaries in the TextGrid. When the coder has set the boundaries,
## they is written to the TextGrid with a code.
##
## The script is written October 2011 by jthoegersen@hum.ku.dk and is GNU/GPL
##

string$ = "ede"

filename$ = selected$ ("TextGrid")

#Open long sound file... L:\Korpus\lydfiler\'filename$'.wav

select TextGrid 'filename$'

tiers = Get number of tiers

lastTier$ = Get tier name... tiers

if lastTier$ = "'string$'-endelse"
    beginPause ("Fejl!")
    comment ("Tieret findes allerede. Slet tieret?")
    delete = endPause ("Ja", 0)

    if delete = 1
        Remove tier... tiers
    endif

endif

Insert interval tier... tiers+1 'string$'-endelse

tiers = Get number of tiers

intervals = Get number of intervals... 1

for interval to intervals

    select TextGrid 'filename$'
    label$ = Get label of interval... 1 interval

    if endsWith (label$, string$)

        pos_label$ = Get label of interval... 5 interval

        if index_regex("'pos_label$'", "(EGEN|N|NUM|ADV)") = 0

            start = Get starting point... 1 interval
            end = Get end point... 1 interval

            Insert boundary... tiers end

            plus LongSound 'filename$'

            View & Edit

            editor TextGrid 'filename$'
                Select... start end+0.05
                Zoom to selection
                Play... start end+0.05
            endeditor
            pause Marker 'string$'-endelsen

            minus LongSound 'filename$'

            stringIntervals = Get number of intervals... tiers
            Set interval text... tiers stringIntervals-1 'string$'

            plus LongSound 'filename$'

            editor TextGrid 'filename$'
                Close
            endeditor

        endif
    endif
endfor

select LongSound 'filename$'
Remove
select TextGrid 'filename$'
Save as text file... L:\Korpus\assimilationer\filename$'_'string$'-endelse.TextGrid

A script for manual coding of features. The coder’s input is written to the TextGrid

## The script searches for words ending in a certain string of letters in adjectives and verbs
## (i.e. words that are not of other Parts of Speech). If the string is found, the corresponding
## sound is extracted and played for the coder. When the coder has decided on the proper code, he or she
## enters it, and it is written to the TextGrid. The coder can listen to the extract any number of times,
## and cancel the task if in doubt.
## There is no "undo".
##
## The script is written October 2011 by jthoegersen@hum.ku.dk and is GNU/GPL
##

string$ = "ede"

filename$ = selected$ ("TextGrid")

Open long sound file... L:\Korpus\lydfiler\'filename$'.wav

select TextGrid 'filename$'
tiers = Get number of tiers

lastTier$ = Get tier name... tiers

if lastTier$ = "'string$'-assimilation"
    beginPause ("Fejl!")
    comment ("Tieret findes allerede. Slet tieret?")
    delete = endPause ("Ja", 0)

    if delete = 1
        Remove tier... tiers
    endif

endif

Insert interval tier... tiers+1 'string$'-assimilation

tiers = Get number of tiers

intervals = Get number of intervals... 1

for interval to intervals

    select TextGrid 'filename$'
    label$ = Get label of interval... 1 interval

    if endsWith (label$, string$)

        pos_label$ = Get label of interval... 5 interval

        if index_regex("'pos_label$'", "(EGEN|N|NUM|ADV)") = 0

            start = Get starting point... 1 interval
            end = Get end point... 1 interval
            endCut = 'end'+0.05
            startCut = 'start'-0.025

            Insert boundary... tiers start
            Insert boundary... tiers end

            select LongSound 'filename$'

            Extract part... startCut endCut no

            playagain = 1

            while playagain = 1
                Play
                beginPause ("Spil igen?")
                playagain = endPause ("Spil igen", "Fortsæt", 1)
            endwhile

            Remove

            beginPause ("Assimileret?")
            comment ("Er endelsen assimileret?")
            endelse = endPause("Ja", "Nej", "Cancel", 0)

            if endelse <> 3

                select TextGrid 'filename$'

                tttInterval = Get interval at time... tiers start

                if endelse = 1
                    Set interval text... tiers tttInterval \dh
                elsif endelse = 2
                    Set interval text... tiers tttInterval \dh\sw
                endif

            elsif endelse = 3

                select TextGrid 'filename$'

                Remove boundary at time... tiers start
                Remove boundary at time... tiers end

                interval = interval - 1

            endif

        endif
    endif
endfor

select LongSound 'filename$'
Remove
select TextGrid 'filename$'
Save as text file... L:\Korpus\assimilationer\filename$'_'string$'.TextGrid

Bulk procedures – TextGrid only

## Snippet for selecting all TextGrids in a directory
form Bulk action
    comment TextGrid directory
    text TextGrid_directory C:\tmp\4\
endform

Create Strings as file list... list 'textGrid_directory$'*.TextGrid

select Strings list
files = Get number of strings

for file to files
    select Strings list
    filename$ = Get string... 'file'

    Read from file... 'textGrid_directory$''filename$'
##
##
    Remove
endfor
select Strings list
Remove

Bulk procedures – TextGrid AND Sound files

## Snippet for selecting TextGrid and wav file pairs in a directory

form Bulk action
    comment TextGrid directory
    text TextGrid_directory C:\tmp\
    comment Sound in directory
    text SoundIn_directory C:\tmp\
endform

Create Strings as file list... list 'textGrid_directory$'*.TextGrid
Change... ".TextGrid" "" 0 Literals
select Strings list
files = Get number of strings

for file to files
    select Strings list
    filename$ = Get string... 'file'

    Open long sound file... 'soundIn_directory$''filename$'.wav
    Read from file... 'textGrid_directory$''filename$'.TextGrid
##
##
    select TextGrid 'filename$'
    Remove
    select LongSound 'filename$'
    Remove
endfor

select Strings list
Remove
select Strings list
Remove

Pretonic vowels

## This snippet finds words with vowels before main stress
intervals = Get number of intervals... 6
for interval to intervals
    label$ = Get label of interval... 6 interval
    stressed = index (label$, "2")
    vowel = index_regex (label$, "(i|e|E|z|a|A|y|q|Q|x|u|o|c|C|X|0)")
    if vowel < stressed
        printline 'label$'
    endif
endfor