-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathaligntier.praat
131 lines (114 loc) · 3.2 KB
/
aligntier.praat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
include procs.praat
# Settings loads: phonetier_name$, wordtier_name$, cantier_name$, tmpfile$,
# orttier_name$, pythonex$, boundary_margin
@loadSettings:
# Load editor and longsound info: sound_file$, sound_object$,
# textgrid_object$, selected_tier, sound_duration, pitch_on,
# intensity_on, spectrum_on, formant_on, pulses_on
@loadFileInfo:
# Extract the tier
Extract entire selected tier
endeditor
# Select the tier and convert it to a table and write it to a file
extracted_tier$ = selected$("TextGrid", 1)
Down to Table: "no", 6, "yes", "no"
Save as tab-separated file: tmpfile$
# Remove all the created temporary objects
Remove
select TextGrid 'extracted_tier$'
Remove
# Write the tier specific settings
writeFileLine("isettings",
..."WAV: ", sound_file$)
# Remove the tiers if they already exist
selectObject: textgrid_object$
number_of_tiers = Get number of tiers
tiernumber = 1
while tiernumber < number_of_tiers
nametier$ = Get tier name: tiernumber
if nametier$ = phonetier_name$ or nametier$ = wordtier_name$ or nametier$ = cantier_name$ or nametier$ = llhtier_name$ or nametier$ = orttier_name$
Remove tier: tiernumber
else
tiernumber = tiernumber + 1
endif
number_of_tiers = Get number of tiers
endwhile
# Get the index the tiers
selectObject: textgrid_object$
phonetier_number = -1
llhtier_number = -1
wordtier_number = -1
cantier_number = -1
orttier_number = -1
if phonetier_name$ <> ""
@indexOfTier: phonetier_name$
phonetier_number = indexOfTier.number
endif
if orttier_name$ <> ""
@indexOfTier: orttier_name$
orttier_number = indexOfTier.number
if indexOfTier.inserted == 1
if phonetier_name$ <> ""
phonetier_number = phonetier_number + 1
endif
endif
endif
if llhtier_name$ <> ""
@indexOfTier: llhtier_name$
llhtier_number = indexOfTier.number
if indexOfTier.inserted == 1
if phonetier_name$ <> ""
phonetier_number = phonetier_number + 1
endif
if orttier_name$ <> ""
orttier_number = orttier_number + 1
endif
endif
endif
if wordtier_name$ <> ""
@indexOfTier: wordtier_name$
wordtier_number = indexOfTier.number
if indexOfTier.inserted == 1
if phonetier_name$ <> ""
phonetier_number = phonetier_number + 1
endif
if orttier_name$ <> ""
orttier_number = orttier_number + 1
endif
if llhtier_name$ <> ""
llhtier_number = llhtier_number + 1
endif
endif
endif
if cantier_name$ <> ""
@indexOfTier: cantier_name$
cantier_number = indexOfTier.number
if indexOfTier.inserted == 1
if phonetier_name$ <> ""
phonetier_number = phonetier_number + 1
endif
if orttier_name$ <> ""
orttier_number = orttier_number + 1
endif
if llhtier_name$ <> ""
llhtier_number = llhtier_number + 1
endif
if wordtier_name$ <> ""
wordtier_number = wordtier_number + 1
endif
endif
endif
# Do the actual alignment
system 'pythonex$' align.py tier
# Close the editor for more speed
editor: textgrid_object$
Close
endeditor
@insertTableTextGrid: tmpfile$, textgrid_object$, phonetier_name$,
... orttier_name$, wordtier_name$, cantier_name$, llhtier_name$,
... phonetier_number, orttier_number, wordtier_number, cantier_number,
... llhtier_number
# Reselect the TextGrid and re-open editor
selectObject: textgrid_object$
plusObject: sound_object$
Edit