-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextract_f0_from_points__and_matching_intervalLabel.praat
executable file
·100 lines (83 loc) · 3.49 KB
/
extract_f0_from_points__and_matching_intervalLabel.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
# extracts_f0_from_points_and_matching_interval_label.praat (2018)
#
# Reads sound files and its TextGrid tier for each of the sounds and it can get:
# a) labels from a point tier
# b) time of point
# c) F0 of wav at that time
# d) Label in an upper or lower interval tier
#
# The output is a txt (tab separated) that is saved in the same folder of your files. Name of file: "f0_log.txt"
#
#
# INSTRUCTIONS
# 0. You need a .wav with its Textgrid saved in the same folder and with at least 1 point tier and 1 interval tier.
# 1. Run
# 2. FORM EXPLANATIONS:
# In the first field you must write the path of the folder where your files are kept
# in a mac something like: /Users/yourName/Desktop
# for windows: C:\Users\yourUserName\Desktop
# if you have a linux, you don't need me to tell you your path
#
# Any feedback is welcome, please if you notice any mistakes or come up with anything that can improve this script, let me know!
#
# Wendy Elvira-García
# Laboratory of Phonetics (University of Barcelona)
#
#
##############################################################################################################
if praatVersion < 5363
exit Your Praat version is too old. Download at least version 5.3.63
endif
form extract F0_point_and_labels_from_interval
sentence Folder /Users/weg/Desktop/n/
comment Which tier do you want to use to extract the data (point tier)?
integer tier 2
comment From which matching interval tier do you want to extract labels?
integer tierMatchingLabel 1
comment Parameters for the analysis of F0
integer f0_floor 75
integer f0_ceiling 600
endform
########################################
#folder$ = chooseDirectory$ ("Choose a directory to read")
#creates txt file
writeFileLine: folder$+ "/"+ "f0_log.txt" , "Filename", tab$, "PointLabel", tab$, "time of Point", tab$, "fo", tab$, "labelIntervalInOtherTier"
Create Strings as file list: "list", folder$+ "/" +"*.wav"
numberOfFiles = Get number of strings
#empieza el bucle
for ifile to numberOfFiles
###################### ACCIONES PARA TODOS LOS archivos #############################
select Strings list
fileName$ = Get string: ifile
appendFile: folder$+ "/"+ "f0_log.txt" , fileName$, tab$
base$ = fileName$ - ".wav"
# Lee el Sonido
mySound = Read from file: folder$+ "/" + base$ + ".wav"
# Lee el TextGrid
myText= Read from file: folder$ +"/"+ base$ + ".TextGrid"
selectObject: mySound
myPitch= To Pitch: 0, f0_floor, f0_ceiling
#To Pitch (ac): 0, 75, 15, 0, 0.03, 0.45, 0.01, 0.35, 0.14, 600
myPitchTier= Down to PitchTier
removeObject: myPitch
selectObject: myText
numberOfPoints= Get number of points: tier
# for each point in the textgrid, get the time of the point and the F0 and that point, then writes it down in txt file
for point to numberOfPoints
#gets the time of the point
selectObject: myText
timeOfPoint= Get time of point: tier, point
labelOfPoint$= Get label of point: tier, point
intervalInOtherTier = Get interval at time: tierMatchingLabel, timeOfPoint
labelIntervalInOtherTier$ = Get label of interval: tierMatchingLabel, intervalInOtherTier
#extracts f0 values
selectObject: myPitchTier
f0_value = Get value at time: timeOfPoint
f0_value$ = fixed$ (f0_value, 0)
#lo escribe
appendFile: folder$+ "/"+ "f0_log.txt" , labelOfPoint$, tab$, timeOfPoint, tab$, f0_value$, tab$, labelIntervalInOtherTier$, tab$
endfor
appendFileLine: folder$+ "/"+ "f0_log.txt" , tab$
removeObject: mySound, myText, myPitchTier
endfor