# The script for creating stimuli by resyntesis, swapping the pitch contours in Q2 <> Q3 minimal pair. # CC-by Pärtel Lippus 20019-2024 form Sada stiimulit comment Folder path with base word wav files text baas_kataloog /users/partel/ownCloud/proj/EEG_valde_2016/stiimulid_2019/RECS/0001_baassonad/ comment Folder path for resulting stimuli text tulemused /users/partel/ownCloud/proj/EEG_valde_2016/stiimulid_2019/RECS/0001_stim3_f0/ endform nimek = Create Strings as file list: "nimekiri", baas_kataloog$ + "*.TextGrid" faile = Get number of strings for f to faile selectObject: nimek tg$ = Get string: f if left$(tg$, 2) <> "Q1" failinimi$ = tg$ - ".TextGrid" kvantiteet$ = left$ (failinimi$, 2) wav1 = Read from file: baas_kataloog$ + failinimi$ + ".wav" tg1 = Read from file: baas_kataloog$ + failinimi$ + ".TextGrid" dur1 = Get total duration failinimi2$ = if kvantiteet$ = "Q2" then replace$(failinimi$, "Q2", "Q3", 1) else replace$(failinimi$, "Q3", "Q2", 1) fi wav2 = Read from file: baas_kataloog$ + failinimi2$ + ".wav" tg2 = Read from file: baas_kataloog$ + failinimi2$ + ".TextGrid" dur2 = Get total duration # Get the segmental boundary times from TG for first base word h_kiht = 3 selectObject: tg1 algus1_s = Get starting point: h_kiht, 1 ots1_s = Get end point: h_kiht, 1 algus1_a1 = Get starting point: h_kiht, 2 ots1_a1 = Get end point: h_kiht, 2 algus1_t = Get starting point: h_kiht, 3 ots1_t = Get end point: h_kiht, 3 algus1_a2 = Get starting point: h_kiht, 4 ots1_a2 = Get end point: h_kiht, 4 # Get the segmental boundary times from TG for second base word selectObject: tg2 algus2_s = Get starting point: h_kiht, 1 ots2_s = Get end point: h_kiht, 1 algus2_a1 = Get starting point: h_kiht, 2 ots2_a1 = Get end point: h_kiht, 2 algus2_t = Get starting point: h_kiht, 3 ots2_t = Get end point: h_kiht, 3 algus2_a2 = Get starting point: h_kiht, 4 ots2_a2 = Get end point: h_kiht, 4 pitch1 = Create PitchTier: failinimi$, 0, dur1 selectObject: wav2 tmp1 = To Pitch: 0, 100, 400 pitch2 = Down to PitchTier #v1 p1 = Get high index from time: algus2_a1 p2 = Get low index from time: ots2_a1 for tp from p1 to p2 selectObject: pitch2 p_f0 = Get value at index: tp p_aeg = Get time from index: tp selectObject: pitch1 Add point: algus1_a1 + (p_aeg-algus2_a1)/(ots2_a1-algus2_a1)*(ots1_a1-algus1_a1), p_f0 endfor #v2 selectObject: pitch2 p1 = Get high index from time: algus2_a2 p2 = Get low index from time: ots2_a2 for tp from p1 to p2 selectObject: pitch2 p_f0 = Get value at index: tp p_aeg = Get time from index: tp selectObject: pitch1 Add point: algus1_a2 + (p_aeg-algus2_a2)/(ots2_a2-algus2_a2)*(ots1_a2-algus1_a2), p_f0 endfor selectObject: wav1 tmp4 = To Manipulation: 0.01, 100, 400 plusObject: pitch1 Replace pitch tier selectObject: tmp4 stim = Get resynthesis (overlap-add) Write to WAV file: tulemused$ + failinimi$ + "_" + "f0_manip_" + left$(failinimi2$,2) + ".wav" Remove # clean up selectObject: tmp1 plusObject: pitch1 plusObject: pitch2 plusObject: wav1 plusObject: wav2 plusObject: tg1 plusObject: tg2 Remove endif endfor ### END ###