You can do that in a few steps. First, add an additional 'no'
to layer 2:
#Select TexGrid
selectObject: 1
number = Get number of intervals: 1
for i from 1 to number
time_start = Get start point: 1, i
#time_end = Get end point: 1, i
name$ = Get label of interval: 1, i
point$ = Get label of point: 2, i
Insert point: 2, time_start, "no"
endfor
Then, extract the information from layer 2 and save it to a file:
#Select TextGrid
selectObject: 1
number = Get number of points: 2
for n from 1 to number
accent_time = Get time of point: 2, n
syllable = Get interval at time: 1, accent_time
syllable$ = Get label of interval: 1, syllable
accent$ = Get label of point: 2, n
writeFileLine: "myFile.txt", accent$
endfor
As the last step, you need to remove those additional 'no'
's from your outcome. Let's do that in Python (Mention all the pitch shapes you have, so the program knows what lines you want to get rid of):
fo = open("myFile.txt", "r")
st = fo.read();
lis = st.split()
fo.close()
for i, choice in enumerate(lis):
if choice == 'H*L' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'H*' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*H' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L%' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'H%' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '!H*L' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '!H*' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'H*L?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '..L' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*HL' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '*?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*H?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'H*?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '..H' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '!H' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'H!' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'HH*L' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '!H*L?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == '.L' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*!H' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'L*HL?' and lis[i-1] == 'no':
lis.pop(i-1)
elif choice == 'LH*L' and lis[i-1] == 'no':
lis.pop(i-1)
with open("output.txt", "w") as my_file:
for i in lis:
my_file.write(i + "\n")