-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnorm.praat.txt
143 lines (126 loc) · 5.35 KB
/
norm.praat.txt
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
132
133
134
135
136
137
138
139
140
141
142
143
#
# Praat script for measuring vowels for NORM
# Version 3.4; Released 2010-05-25
#
# http://qc.gphemsley.org/courses/LCD/391.3/2010-01/
#
# Copyright (C) 2010 Gordon P. Hemsley
# Licensed under a simplified BSD License
# See LICENSE file for more details.
#
##############################################################################
### INSTRUCTIONS ###
##############################################################################
#
# Before you use this script, you must edit the settings in the next section.
#
# The script will not function at all if you do not specify a speaker.
# Do not use spaces or other special characters in the name of the speaker.
#
# If you would like the output file to be put somewhere other than the current
# directory, specify that in the filepath, relative to this file.
#
# How To Use This Script:
#
# 1) In Praat, load the script into "Log script 3" or "Log script 4" by
# entering the full path of the script into the menu accessed by executing
# [ Query > Log settings... ].
#
# 2) To measure monophthongs, put the cursor at the desired point or select an
# entire segment to get the mean measurements over that range.
#
# 3) To measure diphthongs, you will have to run the script twice. For the
# first run, select the initial steady-state position as if it were a
# monophthong. For the second run, select the glide position.
#
# 4) To run the script, execute [ Query > Log script 3 ] or [ Query > Log
# script 4 ], depending on what you did in Step 1.
#
# 5) In the first menu, specify the word you are measuring and a unique way to
# refer to the vowel you are measuring. (The same vowel should always have
# the same name.) You can use any system you want, as long as you are
# consistent. Click OK when you are done.
#
# 6) The next menu will ask whether you are measuring a monophthong or a
# diphthong. Give an honest answer.
#
# 7) On the second run of a diphthong measurement, the information you enter
# in the first menu is discarded, so you can leave it blank.
#
# 8) If you have measured the initial position of a diphthong, but not its
# glide position, Step 6 above will be different. Instead, it will ask you
# whether you want to measure that glide position or pretend that you had
# measured a monophthong and just move on to a new measurement. Again, be
# honest.
#
# 9) Once you have completed these steps once, a file will appear with the
# name of your speaker and the file extension '.tsv' (for tab-separated
# file). When you have completed your measurements, you can feed this file
# into NORM and have it plot all your vowels.
#
##############################################################################
### SETTINGS ###
##############################################################################
# Add speaker name between quotation marks.
speaker$ = ""
# Specify which directory to put the log files in.
# Put path between quotation marks. (Do not include file name.)
# Be sure to include trailing slash.
# (Leave empty for current directory.)
filepath$ = ""
##############################################################################
### DON'T EDIT BELOW THIS LINE ###
##############################################################################
# Prompt the user for information about the vowel
form Record vowel data
sentence Word
word Vowel_name
endform
# Set defaults
measure_glide = 0
phthong = 1
# Prepare filenames
data_file$ = filepath$ + speaker$ + ".tsv"
glide_file$ = filepath$ + "praat.norm.glide." + speaker$ + ".txt"
# Check to see if there is a glide open
if ( fileReadable ( glide_file$ ) )
beginPause ( "Measure glide?" )
comment ( "You have a glide measurement pending. Would you like to measure it now?" )
measure_glide = endPause ( "Skip glide", "Measure glide", 2 )
endif
# If there is no glide open, or an open glide was skipped,
# ask what we are going to measure now.
if ( ( measure_glide == 0 ) || ( measure_glide == 1 ) )
beginPause ( "Select phthong" )
comment ( "Please select phthong" )
phthong = endPause ( "Monophthong", "Diphthong", 1 )
endif
cursor = Get cursor
f1 = Get first formant
f2 = Get second formant
f3 = Get third formant
# Write to the file
if ( !fileReadable ( data_file$ ) )
fileappend 'data_file$' Speaker'tab$'Vowel'tab$'Word'tab$'F1'tab$'F2'tab$'F3'tab$'F1g'tab$'F2g'tab$'F3g'newline$'
endif
# If we have to measure a glide, write the values at the end of the line.
# If we skip an expected glide measurement, finish the line off empty.
if ( measure_glide != 0 )
if ( measure_glide == 2 )
fileappend 'data_file$' 'f1:0''tab$''f2:0''tab$''f3:0''newline$'
elsif ( measure_glide == 1 )
fileappend 'data_file$' 'tab$''tab$''newline$'
endif
filedelete 'glide_file$'
endif
# If we are measuring a new diphthong, write the beginning of the line.
# Otherwise, write the full line.
if ( measure_glide != 2 )
if ( phthong == 2 )
fileappend 'data_file$' 'speaker$''tab$''Vowel_name$''tab$''Word$' ('cursor:4')'tab$''f1:0''tab$''f2:0''tab$''f3:0''tab$'
# Create temp file to keep track of glides.
data_file$ > 'glide_file$'
else
fileappend 'data_file$' 'speaker$''tab$''Vowel_name$''tab$''Word$' ('cursor:4')'tab$''f1:0''tab$''f2:0''tab$''f3:0''tab$''tab$''tab$''newline$'
endif
endif