# The script for creating stimuli by resyntesis, lengthening of V1 in CVCV type of words # This script was originally created for Lippus et al 2009 JPhon # CC-by Pärtel Lippus 2007-2024 # mitu_korda = number of stimuli # varieeritava_esimene = duration of the first stimulus # samm = time step form Sada stiimulit comment folder path of the source files text baas_kataloog /users/partel/ownCloud/proj/EEG_valde_2016/stiimulid_2019/RECS/0001_baassonad/ integer Mitu_korda 9 positive Varieeritava_esimene_(ms) 50 positive samm 30 choice Varieeritakse 1 button vokaali button konsonanti comment Folder path of destination where the stimuli will be saved. text tulemused /users/partel/ownCloud/proj/EEG_valde_2016/stiimulid_2019/RECS/0001_stim/ comment Yes if change the f0 contour. the new contour should be saved as a PitchTier object boolean Muuda_ka_F0_kontuuri 0 boolean Kasuta_salvestatud_F0_kontuuri 0 sentence PitchTier_aadress C:\Documents and Settings\partel\Desktop\tajutest\temp\ sentence PitchTier_failinimi untitled comment yes if change the V2 duration (by +-1 x samm) boolean Muuda_ka_V2_kestust 0 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 failinimi$ = tg$ - ".TextGrid" tmp1 = Read from file: baas_kataloog$ + failinimi$ + ".wav" tmp2 = Read from file: baas_kataloog$ + failinimi$ + ".TextGrid" # Gets the segment boundaries from TextGrid selectObject: "TextGrid " + failinimi$ h_kiht = 3 algus_s = Get starting point: h_kiht, 1 ots1_s = Get end point: h_kiht, 1 ots_s = ots1_s - 0.0001 algus_a1 = Get starting point: h_kiht, 2 ots1_a1 = Get end point: h_kiht, 2 ots_a1 = ots1_a1 - 0.0001 algus_t = Get starting point: h_kiht, 3 ots1_t = Get end point: h_kiht, 3 ots_t = ots1_t - 0.0001 algus_a2 = Get starting point: h_kiht, 4 ots1_a2 = Get end point: h_kiht, 4 ots_a2 = ots1_a2 - 0.0001 # calculate duration for log dur_s = (ots_s - algus_s) * 1000 dur_a1 = (ots_a1 - algus_a1) * 1000 dur_t = (ots_t - algus_t) * 1000 dur_a2 = (ots_a2 - algus_a2) * 1000 # get the Quantity degree from the filename kvantiteet$ = left$ (failinimi$, 2) # log the durations of the original file appendFile: tulemused$ + "info.txt", "Algse faili " + failinimi$ + " ja muudetud failide andmed:" + newline$ appendFile: tulemused$ + "info.txt", "Algkestused:", newline$, "C1", tab$, round(dur_s), newline$, "V1", tab$, round(dur_a1), newline$, "C2", tab$, round(dur_t), newline$, "V2", tab$, round(dur_a2), newline$ # start manipulation select Sound 'failinimi$' To Manipulation... 0.01 100 400 select Sound 'failinimi$' faililopp = Get finishing time # If you chose to manipulate the duration this makes a pause and lets you do the manipulations # I have not used this for the actual stimuli if muuda_ka_F0_kontuuri = 1 pause Vali Manipulation 'failinimi$'>Edit. Tee F0 muutused ja j‰tka. Extract pitch tier Write to PitchTier spreadsheet file... 'tulemused$''failinimi$'.PitchTier Remove fileappend "'tulemused$'info.txt" Pıhitooni muudeti: 'failinimi$'.PitchTier'newline$' endif if kasuta_salvestatud_F0_kontuuri = 1 Read from file... 'pitchTier_aadress$''pitchTier_failinimi$'.PitchTier select PitchTier 'pitchTier_failinimi$' plus Manipulation 'failinimi$' Replace pitch tier select PitchTier 'pitchTier_failinimi$' Remove fileappend "'tulemused$'info.txt" Pıhitooni muutmiseks kasutati faili 'pitchTier_aadress$''pitchTier_failinimi$'.PitchTier'newline$' endif # varieeritakse = 1 manipulates the V1 dur; varieeritakse 2 changes the C2 dur if varieeritakse = 1 for muuda_ka_V2_kestust from 0 to 1 # this lengthens the V2 duration for Q1 and Q2 base words and shortens for Q3 if muuda_ka_V2_kestust = 0 muutuja_V2 = dur_a2 elsif muuda_ka_V2_kestust = 1 if kvantiteet$ = "Q3" muutuja_V2 = dur_a2 + samm else muutuja_V2 = dur_a2 - samm endif appendFile: tulemused$ + "info.txt", "Algset V2 kestust muudeti: ", round(dur_a2), " ms > ", round(muutuja_V2), " ms.", newline$ endif v2info$ = "V2" +"_"+ string$(round(muutuja_V2)) # this is the actual manipulation, goes for as many times as you set in the beginning of the script for kord to mitu_korda # calcluate the new dur of the stimulus V1: duration of fist stimulus + repetition * timestep muutuja = varieeritava_esimene + (kord * samm - samm) Create DurationTier... shorten 0 faililopp Add point... algus_s dur_s/dur_s Add point... ots_s dur_s/dur_s Add point... algus_a1 muutuja/dur_a1 Add point... ots_a1 muutuja/dur_a1 Add point... algus_t dur_t/dur_t Add point... ots_t dur_t/dur_t Add point... algus_a2 muutuja_V2/dur_a2 Add point... ots_a2 muutuja_V2/dur_a2 select Manipulation 'failinimi$' plus DurationTier shorten Replace duration tier select Manipulation 'failinimi$' Get resynthesis (PSOLA) Scale peak: 0.99 Write to WAV file: tulemused$ + failinimi$ + "_" + "vok" + string$(muuda_ka_V2_kestust+1) + "_" + string$(kord) + "_" + string$(muutuja) + "_" + v2info$ + ".wav" Remove select DurationTier shorten Remove appendFile: tulemused$ + "info.txt", failinimi$ + "_" + "vok" + string$(muuda_ka_V2_kestust+1) + "_" + string$(kord) + "_" + string$(muutuja) + "_" + v2info$, newline$ endfor endfor # this part does the manipulation if the target segment is C2 elsif varieeritakse = 2 for kord to mitu_korda muutuja = varieeritava_esimene + (kord * samm - samm) Create DurationTier... shorten 0 faililopp Add point... algus_s dur_s/dur_s Add point... ots_s dur_s/dur_s Add point... algus_a1 dur_a1/dur_a1 Add point... ots_a1 dur_a1/dur_a1 Add point... algus_t muutuja/dur_t Add point... ots_t muutuja/dur_t Add point... algus_a2 muutuja_V2/dur_a2 Add point... ots_a2 muutuja_V2/dur_a2 select Manipulation 'failinimi$' plus DurationTier shorten Replace duration tier select Manipulation 'failinimi$' Get resynthesis (PSOLA) Write to WAV file... 'tulemused$''failinimi$'_kons'kord'_'muutuja'.wav Remove select DurationTier shorten Remove fileappend "'tulemused$'info.txt" 'failinimi$'_kons'kord'_'muutuja''newline$' endfor endif fileappend "'tulemused$'info.txt" Kokku 'mitu_korda' stiimulit, samm 'samm' ms.'newline$''newline$''newline$' select Manipulation 'failinimi$' Remove # clean up selectObject: tmp1 plusObject: tmp2 Remove endfor ### END ###