-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev2.praat
More file actions
145 lines (111 loc) · 4.67 KB
/
Copy pathdev2.praat
File metadata and controls
145 lines (111 loc) · 4.67 KB
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
144
145
# Start with getting...
# 1. mean of intensity in final section of IPUs, section lasting 200 ms/300 ms/500 ms/1000 ms DONE
# 2. mean of pitch in ^^ DONE
# 3. python for CSV of IPU_Stops that preced a Smooth Switch
# PRAAT SCRIPT NEEDS TO KNOW WHICH WAV FILE TO SELECT >>DONEE
# AND missing Defining a Smooth Switch in the Python
# 4. jitter, etc., in ^^
# 5. pitch slope in ^^
# CSV files...
# IPO Task for Quiet and 70 (2 total)
# FTO Task for Quiet PositiveFTO and 70 Positive FTO (2 total)
# desired Praat CSV output file architecture
# 1. create separate CSVs for each of mean intensity, mean pitch, jitter, etc.
# do something like: init last_filename = first name, get current_filename, for loop through all rows but if last != current use current filename
# 2. create new columns as appropriate, eg. mean in last 200 ms, last 300 ms, etc., for each CSV
# add those to the right of WAV filename , Original CSV Row Num , Condition , Type , Group , Replicate, Talker, IPU_Duration , IPU_Stop
# Input CSV file format, preprocessed with a Python script
#
# Columns in input CSV:
# 1. WAV_Filename: the corresponding audio recording that each IPU belongs to
# 2. Original_IPU_Row
# 3. Condition
# 4. Type
# 5. Group
# 6. Replicate
# 7. Talker
# 8. IPU_Start
# 9. IPU_Stop
# 10. IPU_Duration
# 11. NumSyll
# 12. LeveldB
# 11. isOverlapWithin
# 13. Post_IPU_FTO: the FTO that follows each IPU, as obtained from the FTO CSV
# 14. Original_FTO_Row
# 15. isTargetIPU: whether the IPU in this row is one we should analyze
# 16. postIPU_Switch_Type: the nature of the switch, either "Smooth" or "Hesitant"
#clear old messages in the info window
clearinfo
# select files
form IntensityExtraction
sentence directory "C:/Users/Ludens/Desktop/data/"
sentence wav_file "brownfox.wav"
sentence csv_file "q211fox.csv"
endform
sound1Path$ = 'directory$' + 'wav_file$'
csv1Path$ = 'directory$' + 'csv_file$'
# create Sound Object
sound1 = Read from file: sound1Path$
sampling_rate = 22050
# read CSV file
csv1 = Read Table from comma-separated file: csv1Path$
# store in an array the IPU ending times
ipu_ends# = Get all numbers in column... IPU_Stop
# define IPU-final sections to be analyzed
sectionDuration = 0.2
sectionEnd# = zero# (size (ipu_ends#))
sectionStart# = zero# (size (ipu_ends#))
for i from 1 to size (ipu_ends#)
# Define the start time for a final 200 ms section
sectionEnd# [i] = ipu_ends# [i]
sectionStart# [i] = sectionEnd# [i] - sectionDuration
if sectionStart# [i] < sectionDuration
sectionStart# [i] = 0
endif
endfor
# 1. create the Intensity Object
selectObject: sound1
intensity_pitchFloor = 75
intensity_timeStep = 1/sampling_rate
intensityObj = To Intensity: intensity_pitchFloor, intensity_timeStep
selectObject: intensityObj
# 1.1 obtain the mean intensities in the IPU-final sections
for i from 1 to size (ipu_ends#)
# make into a ##
meanIntensity = Get mean: sectionStart# [i], sectionEnd# [i], "energy"
# print to console for now, but put into CSV
# appendInfoLine: "1: ", sectionStart# [i], " 2: ", sectionEnd# [i], " MEAN INTENSITY: ", meanIntensity
endfor
# 2. create the Pitch Object
selectObject: sound1
# filtered autocorrelation is recommended by Praat documentation for measuring intontation
pitch_timeStep = 1/sampling_rate
pitch_floor = 50
pitch_top = 800
pitch_maxCandidates = 15
pitch_veryAcc$ = "no"
pitch_attenAtTop = 0.03
pitch_silenceThres = 0.09
pitch_voicingThres = 0.5
pitch_octaveCost = 0.055
pitch_octaveJumpCost = 0.35
pitch_voicedUnvoicedCost = 0.14
pitchObject = To Pitch (filtered autocorrelation): pitch_timeStep,
...pitch_floor,
...pitch_top,
...pitch_maxCandidates,
...pitch_veryAcc$,
...pitch_attenAtTop,
...pitch_silenceThres,
...pitch_voicingThres,
...pitch_octaveCost,
...pitch_octaveJumpCost,
...pitch_voicedUnvoicedCost
# 2.1 obtain the mean pitch in the IPU-final sections
meanPitchUnit$ = "Hertz"
for i from 1 to size (ipu_ends#)
# make into a ##
meanPitch = Get mean: sectionStart# [i], sectionEnd# [i], meanPitchUnit$
# print to console for now, but put into CSV
appendInfoLine: "1: ", sectionStart# [i], " 2: ", sectionEnd# [i], " MEAN PITCH: ", meanPitch
endfor