您可以通过几个步骤做到这一点。'no'
首先,在第 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
然后,从第 2 层提取信息并将其保存到文件中:
#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
作为最后一步,您需要'no'
从结果中删除那些额外的 's。让我们在 Python 中执行此操作(提及您拥有的所有音高形状,以便程序知道您要删除哪些行):
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")