-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprosodic_data-extraction-2.2.praat
executable file
·1033 lines (807 loc) · 30.8 KB
/
prosodic_data-extraction-2.2.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# prosodic_data_extraction (2.2- April 2016)
#
# Reads sound files and its TextGrid tier for each of the sounds and it can get:
# a) labels form a interval tier,
# b) labels from a point tier,
# c) the tonicity of the syllable (for this you will need to previously have written a tonicity mark in your TextGrid,
# d) duration,
# e) intensity (maximum or at the mean point you can change it on the script)
# f) F0 in Hz at 3 time points per syllable (onset, medium and offset).
# g) F0 in St at 3 time points per syllable (onset, medium and offset), the St reference can be the mean pitch of the sentence or the pitch of the centre of previous interval
# h) The difference in St between the highest point of the last stressed syllable and the last boundary tone in the syllable (for this option you will need a tonicity mark in your TextGrids)
#
#
# The data are written down in a tab-separated txt which can be organised:
#
# a) One line for each Soundfile and all values in groups right aligned (you must specify your maximum number of intervals that the script
# will find in a TextGrid for this option).
# b) One line for each interval
#
#
# The pitch settings can be given by the researcher. But the script is also prepared to carry out the speaker's range setting automatically.
#
#
#
# INSTRUCTIONS
# 0. You need a .wav with its Textgrid saved in the same folder and with at least 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
# The second allows you to choose the name of the txt that will be created
# In the following fields mark the data you want to extract
# for some of them you must supply complementary information such as the number of the tier, or the tonicity mark (if any)
#
# Finally, choose how do you want your data file to be display: (by file or interval)
# If you have chosen any data which involves a Pitch object, a new window will appear in it you will be asked wither to provide your speaker's voice parameters or choose the automatic detection
# of the previous interval.
# You will also be asked for the St referencle in case you have choose it (centre of the previous syllable or mean).
#
# 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 (2014). Prosodic-data-extration v2.2. [Praat script] (Retrieved from http://stel.ub.edu/labfon/en/praat-scripts) Distributed under GNU General Public License.
#
# Wendy Elvira-García
# Laboratory of Phonetics (University of Barcelona)
# wendyelviragarcia @ g m a i l . c o m
#
#
##############################################################################################################
#Limpia los objetos que te has olvidado en el Praat antes de empezar, sí, tb los que no guardaste.
select all
if numberOfSelected() > 0
pause There are objects in the list, the script will remove them
Remove
endif
if praatVersion < 5363
exit This script works only in Praat 5363 or higher
endif
#folder$ = chooseDirectory$ ("Elige la carpeta donde están los archivos que quieres analizar:")
form Prosodic_data_extraction
comment In which folder are your files? (with \ or / at the end)
text Folder /Users/YourUserHere/Desktop/myWavsAndTextGrids/
comment txt name (it will be created in the same folder where the files are kept):
text txtname results_file
comment ¿Which data do you want to extract?
boolean interval_tier_labels 1
comment Tier number for interval tier labels (usually syllable transcription):
integer tier_interval 1
boolean point_tier_labels 1
comment Tier number for point tier labels (usually ToBI):
integer point_tier 5
comment Do you mark anyhow the stressed syllable? If you do, how do you do it?
text tonic ˈ
boolean duration 0
boolean intensity 0
boolean F0_Hz 0
boolean F0_St 0
boolean last_difference 1
comment How do you want the data to be collected?
choice Sort_data 1
option One row per file
option One row per interval
comment Maximum number of intervals TextGrid? (only used for one row per file condtion, alignment to the right purposes)
integer maxint 30
endform
if f0_Hz=1 or f0_St= 1 or last_difference = 1
beginPause ("Data for F0 analysis")
comment ("Which interval tier do you want to use for the F0 extraction")
integer ("extraction_tier", 1)
choice ("range_obtention_method", 2)
option ("Manual")
option ("Hirst's_method")
comment (" ")
if f0_St = 1
comment ("How do you want the St to be calculated?")
choice ("St_reference", 1)
option ("The mean of each file")
option ("The previous syllable")
endif
comment ("You can change here the way how Praat finds the F0 path")
comment ("If you are choosing to obtain the range of the speaker automatically the f0min and f0max here won't be taken on account")
positive ("f0min", 75)
positive ("f0max", 600)
positive ("voicing_threshold", 0.45)
positive ("octave_cost", 0.01)
positive ("octave_jump_cost", 0.35)
positive ("voiced_unvoiced_cost", 0.14)
endPause ("OK", 1)
endif
######################### CREA ARCHIVO DE TABLA Y ENCABEZADOS #########################################
# Crea el archivo txt y dejo preparados 2 encabezados.
arqout$ = folder$ + txtname$ + ".txt"
if fileReadable (arqout$)
pause There is already a file with that name, you will overwrite it
deleteFile: arqout$
endif
# encabezados para una linea por fichero, alineado a la derecha
if sort_data = 1
appendFile: arqout$, "filename", tab$
if interval_tier_labels = 1
for 1 to maxint
appendFile: arqout$, "AFI", tab$
endfor
endif
if tonic$ <> ""
for 1 to maxint
appendFile: arqout$, "Tonicity", tab$
endfor
endif
if point_tier_labels = 1
for 1 to maxint
appendFile: arqout$, "ToBI", tab$
endfor
endif
if duration = 1
for 1 to maxint
appendFile: arqout$, "duration[ms]", tab$
endfor
endif
if intensity = 1
for 1 to maxint
appendFile: arqout$, "intensity", tab$
endfor
endif
if f0_Hz = 1
for 1 to maxint
appendFile: arqout$, "fo1[Hz]", tab$, "fo2[Hz]", tab$, "fo3[Hz]", tab$
endfor
endif
if f0_St = 1
for 1 to maxint
appendFile: arqout$, "fo1[St]", tab$, "fo2[St]", tab$, "fo3[St]", tab$
endfor
endif
if last_difference =1
appendFile: arqout$, "Difference between max F0 in the stressed and last point of the sentence [St]", tab$
endif
appendFile: arqout$, newline$
endif
if sort_data = 2
appendFileLine: arqout$, "Filename", tab$, "n interval", tab$, "AFI", tab$, "Tonicity", tab$, "ToBI", tab$, "Duration [ms]", tab$, "Intensity", tab$, "fo1", tab$, "fo2", tab$, "fo3[Hz]", tab$, "fo1", tab$, "fo2", tab$, "fo3[St]", tab$, "Difference between max F0 in the stressed and last point of the sentence [St]", tab$
endif
################################## BUCLE #####################################
# bucle principal ciérrame al final del script
# Crea la lista de objetos desde el string
Create Strings as file list... list 'folder$'/*.wav
#Hace el bucle con ello
numberOfFiles = Get number of strings
for ifile to numberOfFiles
select Strings list
file$ = Get string... ifile
base$ = file$ - ".wav"
fil$ = folder$ + file$
#lee el archivo de sonido
Read from file... 'folder$'/'file$'
base$ = selected$ ("Sound")
#lee el texgrid
filegrid$ = base$ + ".TextGrid"
Read from file... 'folder$'/'filegrid$'
# Crea objetos intensity y pitch si son necesarios
if intensity = 1
select Sound 'base$'
To Intensity... 100 0.0 no
endif
if f0_Hz=1 or f0_St= 1 or last_difference = 1
if range_obtention_method = 1
select Sound 'base$'
To Pitch (ac)... 0.005 'f0min' 15 no 0.03 'voicing_threshold' 'octave_cost' 'octave_jump_cost' 'voiced_unvoiced_cost' 'f0max'
else
select Sound 'base$'
#To Pitch (ac)... 0.005 50 15 no 0.03 'voicing_threshold' 'octave_cost' 'octave_jump_cost' 'voiced_unvoiced_cost' 650
#f0min = Get minimum... 0 0 Hertz Parabolic
#f0max = Get maximum... 0 0 Hertz Parabolic
#f0min = f0min - 50
#f0max = f0max + 50
#Rename: "pitch_viejo"
#select Sound 'base$'
#To Pitch (ac)... 0.005 'f0min' 15 no 0.03 'voicing_threshold' 'octave_cost' 'octave_jump_cost' 'voiced_unvoiced_cost' 'f0max'
@determine_pitch_floor_hirst
procedure determine_pitch_floor_hirst
mySound = selected("Sound")
To Pitch... 0.01 60 700
q1 = Get quantile... 0 0 0.25 Hertz
q3 = Get quantile... 0 0 0.75 Hertz
Remove
select mySound
floor = q1*0.75
ceiling = q3*2
myPitch = To Pitch... 0.01 floor ceiling
endproc
endif
endif
#condicion de 1 fila por fichero
if sort_data = 1
appendFile: arqout$, base$, tab$
################# BUSCA NOMBRES DE ETIQUETAS Y LOS EXTRAE ##################
############################# ETIQUETAS SILABAS #############################
if interval_tier_labels = 1
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
while numerointervalos < maxint
appendFile: arqout$, "x", tab$
numerointervalos =numerointervalos+1
endwhile
numerointervalos = Get number of intervals: tier_interval
i=1
for i to numerointervalos
etiquetaintervalo$ = Get label of interval: tier_interval, i
appendFile: arqout$, etiquetaintervalo$, tab$
endfor
endif
############################# TONICIDAD #############################
if tonic$ <> ""
select TextGrid 'base$'
tonicidad$ = "0"
numerointervalos = Get number of intervals: tier_interval
while numerointervalos < maxint
appendFile: arqout$, "x", tab$
numerointervalos =numerointervalos+1
endwhile
numerointervalos = Get number of intervals: tier_interval
interval =1
for interval to numerointervalos
numberOfIntervals= Get number of intervals: tier_interval
if interval < (numberOfIntervals -1)
etiquetasiguiente$= Get label of interval: tier_interval, interval+1
primercaracter$ = left$ (etiquetasiguiente$, 1)
if primercaracter$ = tonic$
tonicidad$ = "pretonica"
endif
endif
if interval < (numberOfIntervals -2)
etiquetasiguiente$= Get label of interval: tier_interval, interval+2
primercaracter$ = left$ (etiquetasiguiente$, 1)
if primercaracter$ = tonic$
tonicidad$ = "prepretonica"
endif
endif
if (interval - 1) >= 1
etiquetaanterior$= Get label of interval: tier_interval, interval-1
primercaracter$ = left$ (etiquetaanterior$, 1)
if primercaracter$ = tonic$
tonicidad$ = "postonica"
endif
endif
if (interval - 2) >= 1
etiquetaanteanterior$= Get label of interval: tier_interval, interval-2
primercaracter$ = left$ (etiquetaanteanterior$, 1)
if primercaracter$ = tonic$
tonicidad$ = "pospostonica"
endif
endif
etiquetaintervalo$ = Get label of interval: tier_interval, interval
primercaracter$ = left$ (etiquetaintervalo$, 1)
if primercaracter$ = tonic$
tonicidad$ = "tonica"
endif
appendFile: arqout$, tonicidad$, tab$
endfor
endif
############################# ETIQUETAS ToBI #############################
if point_tier_labels = 1
select TextGrid 'base$'
numeropuntos = Get number of points: point_tier
while numeropuntos < maxint
appendFile: arqout$, "x", tab$
numeropuntos = numeropuntos+1
endwhile
numeropuntos = Get number of points: point_tier
i=1
for i to numeropuntos
etiquetapunto$ = Get label of point: point_tier, i
appendFile: arqout$, etiquetapunto$, tab$
endfor
endif
############################# DURACION ################################################
if duration = 1
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
while numerointervalos < maxint
appendFile: arqout$, "x", tab$
numerointervalos = numerointervalos+1
endwhile
numerointervalos = Get number of intervals: tier_interval
k=1
for k from 1 to numerointervalos
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, k
if label$ <> ""
# pto inicio y pto final
onset = Get starting point: tier_interval, k
offset = Get end point: tier_interval, k
dur = offset-onset
durms = dur*1000
dur$ = fixed$(durms,2)
appendFile: arqout$, dur$, tab$
else
appendFile: arqout$, "x", tab$
endif
endfor
endif
############################ intensity ################################
if intensity = 1
select TextGrid 'base$'
numerointervalos = Get number of intervals... tier_interval
while numerointervalos < maxint
appendFile: arqout$, "x", tab$
numerointervalos = numerointervalos + 1
endwhile
numerointervalos = Get number of intervals... tier_interval
k=1
for k from 1 to numerointervalos
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, k
if label$ <> ""
onset = Get starting point: tier_interval, k
offset = Get end point: tier_interval, k
dur = offset-onset
ptomediointervalo = onset + (dur/2)
select Intensity 'base$'
#Activa esta si quieres la intensity en el pto central del interval
#int = Get value at time... 'ptomediointervalo' Cubic
#Activa esta si quieres la maxima intensity en el interval
int= Get maximum... onset offset Parabolic
int$ = fixed$(int,0)
appendFile: arqout$, int$, tab$
else
appendFile: arqout$, "x", tab$
endif
endfor
endif
##################### F0 Hz ##################################
if f0_Hz = 1
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
while numerointervalos < maxint
appendFile: arqout$, "x", tab$, "x", tab$, "x", tab$
numerointervalos=numerointervalos+1
endwhile
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
k=1
for k to numerointervalos
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, k
if label$ <> ""
onset = Get starting point: tier_interval, k
offset = Get end point: tier_interval, k
dur=offset-onset
ptomediointervalo = onset + (dur/2)
select Pitch 'base$'
pitch1 = Get value at time... onset Hertz Linear
pitch2 = Get value at time... ptomediointervalo Hertz Linear
pitch3 = Get value at time... offset Hertz Linear
#si hay valores undefined hace un PtichTier
if pitch1= undefined or pitch2= undefined or pitch3 = undefined
select Pitch 'base$'
do ("Down to PitchTier")
if pitch1 = undefined
pitch1 = Get value at time: onset
endif
if pitch2=undefined
pitch2 = Get value at time: ptomediointervalo
endif
if pitch3 =undefined
pitch3 = Get value at time: offset
endif
endif
pitch1$ = fixed$ (pitch1,0)
pitch2$ = fixed$ (pitch2,0)
pitch3$ = fixed$ (pitch3,0)
appendFile: arqout$, pitch1$, tab$, pitch2$, tab$, pitch3$, tab$
else
appendFile: arqout$, "x", tab$, "x", tab$, "x", tab$
endif
endfor
endif
#########################################
##################### F0 ST ##################################
if f0_St = 1
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
while numerointervalos < maxint
appendFile: arqout$, "x", tab$, "x", tab$, "x", tab$
numerointervalos= numerointervalos+1
endwhile
if st_reference = 1
select Pitch 'base$'
referencia = do ("Get mean...", 0, 0, "Hertz")
endif
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
k=1
for k to numerointervalos
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, k
if label$ <> ""
onset = Get starting point: tier_interval, k
offset = Get end point: tier_interval, k
dur =offset-onset
ptomediointervalo = onset + (dur/2)
select Pitch 'base$'
pitch1 = Get value at time... onset Hertz Linear
pitch2 = Get value at time... ptomediointervalo Hertz Linear
pitch3 = Get value at time... offset Hertz Linear
#si hay valores undefined hace un smooth y coge los valores smootheados
if pitch1= undefined or pitch2= undefined or pitch3 = undefined
select Pitch 'base$'
do ("Down to PitchTier")
if pitch1 = undefined
pitch1 = Get value at time: onset
endif
if pitch2=undefined
pitch2 = Get value at time: ptomediointervalo
endif
if pitch3 =undefined
pitch3 = Get value at time: offset
endif
endif
#calculo de referencia por el centro de la sílaba precedente
if st_reference = 2
previousInterval = k-1
if previousInterval >= 1
select TextGrid 'base$'
onset = Get starting point: tier_interval, previousInterval
offset = Get end point: tier_interval, previousInterval
dur =offset-onset
ptomediointervalo = onset + (dur/2)
select Pitch 'base$'
referencia = Get value at time... ptomediointervalo Hertz Linear
if referencia = undefined
select Pitch 'base$'
do ("Down to PitchTier")
referencia = Get value at time: ptomediointervalo
endif
endif
#si es la primera sílaba de la frase el valor de referencia es el onset de la sílaba
if previousInterval < 1
onsetk = Get starting point: tier_interval, k
referencia = Get value at time: onsetk Hertz Linear
if referencia = undefined
select Pitch 'base$'
do ("Down to PitchTier")
referencia = Get value at time: onsetk
endif
endif
endif
#calculos para saber los ST
pitch1St = (12 / log10 (2)) * log10 ('pitch1'/'referencia')
pitch2St = (12 / log10 (2)) * log10 ('pitch2'/'referencia')
pitch3St = (12 / log10 (2)) * log10 ('pitch3'/'referencia')
pitch1St$ = fixed$(pitch1St,2)
pitch2St$ = fixed$(pitch2St,2)
pitch3St$ = fixed$(pitch3St,2)
appendFile: arqout$, pitch1St$, tab$, pitch2St$, tab$, pitch3St$, tab$
else
appendFile: arqout$, "x", tab$, "x", tab$, "x", tab$
endif
endfor
endif
################# calcular la ultima bajada ########################
if last_difference = 1
select TextGrid 'base$'
numberOfIntervals = Get number of intervals: tier_interval
i=1
for i to numberOfIntervals
label$ = Get label of interval: tier_interval, i
primercaracter$ = left$ (label$, 1)
if primercaracter$ = tonic$
ultimatonica = i
endif
endfor
onset_tonica = Get starting point: tier_interval, ultimatonica
last_boundary = Get end point: tier_interval, numberOfIntervals-1
select Pitch 'base$'
maxima_f0_ultimo_movimiento = Get time of maximum: onset_tonica, last_boundary, "Hertz", "None"
pitch_max_last_movement = Get value at time... maxima_f0_ultimo_movimiento Hertz Linear
pitch_final = Get value at time... last_boundary Hertz Linear
#si hay valores undefined hace un smooth y coge los valores smootheados
if pitch_max_last_movement= undefined or pitch_final= undefined
select Pitch 'base$'
do ("Down to PitchTier")
if pitch_max_last_movement = undefined
pitch_max_last_movement = Get value at time... maxima_f0_ultimo_movimiento
endif
if pitch_final=undefined
pitch_final = Get value at time... last_boundary
endif
endif
#calculos para saber los ST
diferencia_ultima_bajada = (12 / log10 (2)) * log10 (pitch_final/pitch_max_last_movement)
diferencia_ultima_bajada$ = fixed$ (diferencia_ultima_bajada,2)
appendFile: arqout$, diferencia_ultima_bajada$, tab$
else
appendFile: arqout$, "-", tab$
endif
#################
##################################
#acaba condicion de un archivo por fila
endif
#################
#################
#################
##################################
#################
##################################
#################
#################
################# PARA EXTRAER UNA FILA POR INTERVALO ##################
if sort_data =2
select TextGrid 'base$'
numerointervalos = Get number of intervals: tier_interval
for interval to numerointervalos
appendFile: arqout$, base$, tab$, interval, tab$
############################# ETIQUETAS SILABAS #############################
if interval_tier_labels = 1
select TextGrid 'base$'
etiquetaintervalo$ = Get label of interval... tier_interval interval
appendFile: arqout$, etiquetaintervalo$, tab$
else
appendFile: arqout$, "-", tab$
endif
############################# TONICIDAD #############################
if tonic$ <> ""
select TextGrid 'base$'
tonicidad$ = "0"
numberOfIntervals= Get number of intervals: tier_interval
if interval < (numberOfIntervals -1)
etiquetasiguiente$= Get label of interval: tier_interval, interval+1
primercaracter$ = left$ (etiquetasiguiente$, 1)
if primercaracter$ = tonic$
tonicidad$ = "pretonica"
endif
endif
if interval < (numberOfIntervals -2)
etiquetasiguiente$= Get label of interval: tier_interval, interval+2
primercaracter$ = left$ (etiquetasiguiente$, 1)
if primercaracter$ = tonic$
tonicidad$ = "prepretonica"
endif
endif
if (interval - 1) >= 1
etiquetaanterior$= Get label of interval: tier_interval, interval-1
primercaracter$ = left$ (etiquetaanterior$, 1)
if primercaracter$ = tonic$
tonicidad$ = "postonica"
endif
endif
if (interval - 2) >= 1
etiquetaanteanterior$= Get label of interval: tier_interval, interval-2
primercaracter$ = left$ (etiquetaanteanterior$, 1)
if primercaracter$ = tonic$
tonicidad$ = "pospostonica"
endif
endif
etiquetaintervalo$ = Get label of interval: tier_interval, interval
primercaracter$ = left$ (etiquetaintervalo$, 1)
if primercaracter$ = tonic$
tonicidad$ = "tonica"
endif
appendFile: arqout$, tonicidad$, tab$
else
appendFile: arqout$, "-", tab$
endif
############################# ETIQUETAS ToBI #############################
if point_tier_labels = 1
select TextGrid 'base$'
#Tiene que sacar el punto de ese intervalo y si no hay ninguno que coincida pues en blanco
startPointInterval = Get start point: tier_interval, interval
endPointInterval = Get end point: tier_interval, interval
centrodelintervalo = startPointInterval+ ((endPointInterval - startPointInterval)/2)
punto = Get nearest index from time: point_tier, centrodelintervalo
etiquetapunto$ = Get label of point: point_tier, punto
appendFile: arqout$, etiquetapunto$, tab$
else
appendFile: arqout$, "-", tab$
endif
############################# DURACION ################################################
if duration = 1
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, interval
if label$ <> ""
# pto inicio y pto final
onset = Get starting point: tier_interval, interval
offset = Get end point: tier_interval, interval
dur = offset-onset
durms = dur*1000
dur$ = fixed$(durms,2)
appendFile: arqout$, dur$, tab$
else
appendFile: arqout$, "-", tab$
endif
else
appendFile: arqout$, "-", tab$
endif
############################ intensity ################################
if intensity = 1
select Sound 'base$'
To Intensity... 100 0.0 no
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, interval
if label$ <> ""
onset = Get starting point: tier_interval, interval
offset = Get end point: tier_interval, interval
dur = offset-onset
ptomediointervalo = onset + (dur/2)
select Intensity 'base$'
#Activa esta si quieres la intensity en el pto central del interval
#int = Get value at time... 'ptomediointervalo' Cubic
#Activa esta si quieres la maxima intensity en el interval
int= Get maximum... onset offset Parabolic
int$ = fixed$(int,0)
appendFile: arqout$, int$, tab$
else
appendFile: arqout$, "-", tab$
endif
else
appendFile: arqout$, "-", tab$
endif
##################### F0 Hz ##################################
if f0_Hz = 1
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, interval
if label$ <> ""
onset = Get starting point: tier_interval, interval
offset = Get end point: tier_interval, interval
dur=offset-onset
ptomediointervalo = onset + (dur/2)
select Pitch 'base$'
pitch1 = Get value at time... onset Hertz Linear
pitch2 = Get value at time... ptomediointervalo Hertz Linear
pitch3 = Get value at time... offset Hertz Linear
#si hay valores undefined hace un PtichTier
if pitch1= undefined or pitch2= undefined or pitch3 = undefined
select Pitch 'base$'
do ("Down to PitchTier")
if pitch1 = undefined
pitch1 = Get value at time... onset
endif
if pitch2=undefined
pitch2 = Get value at time... ptomediointervalo
endif
if pitch3 =undefined
pitch3 = Get value at time... offset
endif
endif
pitch1$ = fixed$(pitch1,0)
pitch2$ = fixed$(pitch2,0)
pitch3$ = fixed$(pitch3,0)
appendFile: arqout$, pitch1$, tab$, pitch2$, tab$, pitch3$, tab$
else
appendFile: arqout$, "-", tab$, "-", tab$, "-", tab$
endif
else
appendFile: arqout$, "-", tab$, "-", tab$, "-", tab$
endif
#########################################
##################### F0 ST ##################################
if f0_St = 1
if st_reference = 1
select Pitch 'base$'
referencia = do ("Get mean...", 0, 0, "Hertz")
endif
select TextGrid 'base$'
label$ = Get label of interval: tier_interval, interval
if label$ <> ""
onset = Get starting point: tier_interval, interval
offset = Get end point: tier_interval, interval
dur =offset-onset
ptomediointervalo = onset + (dur/2)
select Pitch 'base$'
pitch1 = Get value at time... onset Hertz Linear
pitch2 = Get value at time... ptomediointervalo Hertz Linear
pitch3 = Get value at time... offset Hertz Linear
#si hay valores undefined hace un smooth y coge los valores smootheados
if pitch1= undefined or pitch2= undefined or pitch3 = undefined
select Pitch 'base$'
do ("Down to PitchTier")
if pitch1 = undefined
pitch1 = Get value at time... onset
endif
if pitch2=undefined
pitch2 = Get value at time... ptomediointervalo
endif
if pitch3 =undefined
pitch3 = Get value at time... offset
endif
endif
#calculo de referencia por el centro de la sílaba precedente
if st_reference = 2
previousInterval = interval-1
if previousInterval >= 1
select TextGrid 'base$'
onset = Get starting point... 'tier_interval' 'previousInterval'
offset = Get end point... 'tier_interval' 'previousInterval'
dur =offset-onset
ptomediointervalo = onset + (dur/2)
select Pitch 'base$'
referencia = Get value at time... ptomediointervalo Hertz Linear
if referencia = undefined
select Pitch 'base$'
do ("Down to PitchTier")
referencia = Get value at time... ptomediointervalo
endif
endif
#si es la primera sílaba de la frase el valor de referencia es el onset de la sílaba
if previousInterval < 1
onsetinterval = Get starting point: tier_interval, interval
referencia = Get value at time... onsetinterval Hertz Linear
if referencia = undefined
select Pitch 'base$'
do ("Down to PitchTier")
referencia = Get value at time... onsetinterval
endif
endif
endif
#calculos para saber los ST
pitch1St = (12 / log10 (2)) * log10 ('pitch1'/'referencia')
pitch2St = (12 / log10 (2)) * log10 ('pitch2'/'referencia')
pitch3St = (12 / log10 (2)) * log10 ('pitch3'/'referencia')
pitch1St$ = fixed$ (pitch1St,2)
pitch2St$ = fixed$ (pitch2St,2)
pitch3St$ = fixed$ (pitch3St,2)
appendFile: arqout$, pitch1St$, tab$, pitch2St$, tab$, pitch3St$, tab$
else
appendFile: arqout$, "-", tab$, "-", tab$, "-", tab$
endif
else
appendFile: arqout$, "-", tab$, "-", tab$, "-", tab$
endif
#########################################
################# calcular la ultima bajada ########################
if last_difference = 1
select TextGrid 'base$'
numberOfIntervals = Get number of intervals: tier_interval
for i to numberOfIntervals
label$ = Get label of interval: tier_interval, i
primercaracter$ = left$ (label$, 1)
if primercaracter$ = tonic$
ultimatonica = i
endif
endfor
onset_tonica = Get starting point: tier_interval, ultimatonica
last_boundary = Get end point: tier_interval, numberOfIntervals-1
select Pitch 'base$'
maxima_f0_ultimo_movimiento = Get time of maximum: onset_tonica, last_boundary, "Hertz", "None"
pitch_max_last_movement = Get value at time... maxima_f0_ultimo_movimiento Hertz Linear
pitch_final = Get value at time... last_boundary Hertz Linear
#si hay valores undefined hace un smooth y coge los valores smootheados
if pitch_max_last_movement= undefined or pitch_final= undefined
select Pitch 'base$'
do ("Down to PitchTier")
if pitch_max_last_movement = undefined
pitch_max_last_movement = Get value at time... maxima_f0_ultimo_movimiento
endif
if pitch_final=undefined
pitch_final = Get value at time... last_boundary
endif
endif
#calculos para saber los ST
diferencia_ultima_bajada = (12 / log10 (2)) * log10 ('maxima_f0_ultimo_movimiento'/'last_boundary')
diferencia_ultima_bajada$ = fixed$ (diferencia_ultima_bajada,2)
appendFile: arqout$, diferencia_ultima_bajada$, tab$