#this script does three tasks related to f0-f1 retrieval #first, get the reference point for measuring the f0-f1 into/out of closure #second, decide exact point of measurement (move 0.005s vs.0.015 by segments) #third,read f0-f1 and return values to user #MAKE SURE:1.line up boundaries on tiers;2.burst is labeled B or b. form Output Directory of Textgrids with F0/F1 points inserted comment Directory path to save the textfiles: comment Example (PC): C:\documents and settings\(username)\desktop\Textgrids\ comment Example (Mac): /Users/miep/Desktop/Textgrids/ text output_directory ~/Desktop/P6 STOPS/ endform n=numberOfSelected ("Sound") echo n='n' m=numberOfSelected ("TextGrid") printline m='m' if n!=m exit ERROR!PLEASE MAKE SURE YOU SELECTED THE SAME NUMBER OF SOUND AND TEXTGRID FILES. endif printline printline List of Sound Files for i to n sound'i' = selected ("Sound", i) printline sound'i' endfor printline printline List of TextGrid Files for i to m textgrid'i'=selected("TextGrid",i) printline textgrid'i' endfor printline printline Word'tab$'label'tab$'F0'tab$''tab$' F1 for i to n select sound'i' label$=selected$ ("Sound") select textgrid'i' p=Get number of intervals... 1 m=(p-1)/2 Insert point tier... 6 F0-F1 call CheckIso #m is the number of repetitions for j to m if iso=1 call GetRefPointsIso call InsertMPIso tr2 tmo elsif iso=0 call GetRefPoints call InsertMP tr1 tr2 tmi tmo endif endfor for j to m if iso=0 Set point text... 6 2*j-1 F0-F1i Set point text... 6 2*j F0-F1o endif select textgrid'i' Write to text file... 'output_directory$''label$'.TextGrid endfor call MeasureFormants endfor procedure CheckIso #returns values of tm, and iso c=1 letter$=mid$(label$,c,1) #checking how many letters is in the root of the word in file name while letter$!="_" c=c+1 letter$=mid$(label$,c,1) endwhile #check if the file name is of the correct type namecheck=index(label$, "_") if namecheck=0 exit ERROR!PLEASE MAKE SURE YOUR SOUND FILE IS CORRECTLY NAMED endif l1$=left$(label$,1) if ((l1$="d") or (l1$="k")) tmo=0.015 else tmo=0.005 endif tmi=0.005 #isolation case iso$=mid$(label$,c+1,1) if ((iso$!="N") and (iso$!="x") and (iso$!="o")) iso=1 else iso=0 endif endproc procedure GetRefPointsIso t1=Get start point... 2 2*j t02=t1+0.001 p=Get interval at time... 3 t02 t2=Get end point... 3 p #t2 is the reference time for F0/F1 out of closure when there is no burst t03=t2+0.00001 #r is the interval of the burst, if it exists; if it doesn't exist, then it's a blank interval r=Get interval at time... 5 t03 #checking whether the lable is B or blank labelb$=Get label of interval... 5 r if ((labelb$="B") or (labelb$="b")) tr2=Get end point... 5 r #tr2 is the reference point for out of closure in this case #check two burst cases elsif ((labelb$="B1") or (labelb$="b1")) y=r+1 labelb2$=Get label of interval... 5 y while ((labelb2$!="B2") and (labelb2$!="b2")) y=y+1 labelb2$=Get label of interval... 5 y endwhile tr2=Get end point... 5 y #otherwise, t2 is the reference point for out of closure else tr2=t2 endif endproc procedure GetRefPoints t1=Get start point... 2 4*(j-1)+2 v=Get interval at time... 2 t1+0.001 tr1=Get end point... 2 v #tr1 is the reference time for F0/F1 into closure t02=tr1+0.01 #q is the interval of the closure q=Get interval at time... 3 t02 t3=Get end point... 3 q t03=t3+0.00001 #r is the interval of the burst, if it exists; if it doesn't exist, then it's a blank interval r=Get interval at time... 5 t03 #checking whether the lable is B or blank labelb$=Get label of interval... 5 r if ((labelb$="B") or (labelb$="b")) tr2=Get end point... 5 r #tr2 is the reference point for out of closure in this case #check two burst cases elsif ((labelb$="B1") or (labelb$="b1")) y=r+1 labelb2$=Get label of interval... 5 y while ((labelb2$!="B2") and (labelb2$!="b2")) y=y+1 labelb2$=Get label of interval... 5 y endwhile tr2=Get end point... 5 y else #otherwise, t3 is the reference point for out of closure tr2=t3 endif endproc procedure InsertMPIso InsertMPIso.tr2 .tmo select textgrid'i' Insert point... 6 .tr2+.tmo Set point text... 6 j F0-F1o endproc procedure InsertMP InsertMP.tr1 .tr2 .tmi .tmo select textgrid'i' Insert point... 6 .tr1-.tmi Insert point... 6 .tr2+.tmo endproc procedure MeasureFormants select sound'i' To Pitch... 0.0 75 600 pitch = selected ("Pitch") select sound'i' To Formant (burg)... 0.0 5 5500 0.025 50 formant=selected ("Formant") select textgrid'i' a=Get number of points... 6 for j to a t=Get time of point... 6 j x=Get interval at time... 1 t word$=Get label of interval... 1 x label$=Get label of point... 6 j #x is the interval number; l is the lable of that interval on tier 1 corresponding to the point in question in tier 6 select pitch f0=Get value at time... t Hertz Linear select formant f1=Get value at time... 1 t Hertz Linear printline 'word$''tab$''label$''tab$''f0''tab$''f1' select textgrid'i' endfor select pitch Remove select formant Remove endproc