##################################################################### # increase-duration-by-msec-for-two-segments.praat ( Written by Kyuchul Yoon kyoon@ling.osu.edu ) # This script lets a user select two intervals and increases/decrease the duration of the intervals # by the amount (in msec) specified in the form # NOTE: For the first target segment, you specify both the beginning and end of it by sweeping over # the target area, but for the second target segment, you only specify the "end" of it because # the beginning of it is assumed to be the end of the first target segment ##################################################################### form Specify files and folders word inFile_(with_wav) basson.wav comment Number of repetitions for FIRST SEGMENT natural numOfRepetition1st 5 comment Milliseconds increase wrt/ original duration real msecDur1st_(in_milliseconds) 10 comment Number of repetitions for SECOND SEGMENT natural numOfRepetition2nd 5 comment Milliseconds increase wrt/ original duration real msecDur2nd_(in_milliseconds) -10 comment A subfolder with the input filename will be created automatically word outInfo cursor.locations.TXT endform folderName$ = inFile$ - ".wav" folderName$ = folderName$ + "--1stSEL-2ndSEL.dur.inc.by.msec--" # First section reminder suffix1st$ = "'numOfRepetition1st'" + "-rep" if msecDur1st > 0 suffix1st$ = suffix1st$ + "-plus-" elsif msecDur1st < 0 suffix1st$ = suffix1st$ + "-minus-" endif suffix1st$ = suffix1st$ + "'msecDur1st'" suffix1st$ = suffix1st$ + "ms" # Second section reminder suffix2nd$ = "'numOfRepetition2nd'" + "-rep" if msecDur2nd > 0 suffix2nd$ = suffix2nd$ + "-plus-" elsif msecDur2nd < 0 suffix2nd$ = suffix2nd$ + "-minus-" endif suffix2nd$ = suffix2nd$ + "'msecDur2nd'" suffix2nd$ = suffix2nd$ + "ms" folderName$ = folderName$ + suffix1st$ folderName$ = folderName$ + "-" folderName$ = folderName$ + suffix2nd$ system mkdir 'folderName$' Read from file... 'inFile$' Rename... inFile finishTime = Get finishing time select Sound inFile Edit editor Sound inFile pause SELECT FIRST SEGMENT Move begin of selection to nearest zero crossing Move end of selection to nearest zero crossing begin1stSel = Get begin of selection end1stSel = Get end of selection len1stTargetSel = end1stSel - begin1stSel pause PICK END OF SECOND SEGMENT Move begin of selection to nearest zero crossing Move end of selection to nearest zero crossing begin2ndSel = end1stSel end2ndSel = Get cursor len2ndTargetSel = end2ndSel - begin2ndSel # INFO printout fileappend 'folderName$'/'outInfo$' filename'tab$'startOf1stSel'tab$'endOf1stSel ... 'tab$'endOf2ndSel'newline$' fileappend 'folderName$'/'outInfo$' 'inFile$''tab$''begin1stSel''tab$''end1stSel' ... 'tab$''end2ndSel''newline$' Select... 0 begin1stSel Extract windowed selection... beginSection Rectangular 1 no Select... begin1stSel end1stSel Extract windowed selection... target1stSection Rectangular 1 no Select... begin2ndSel end2ndSel Extract windowed selection... target2ndSection Rectangular 1 no Select... end2ndSel finishTime Extract windowed selection... endSection Rectangular 1 no Close endeditor select Sound inFile Write to WAV file... 'folderName$'/'folderName$'-orig.wav for k to numOfRepetition1st # 1st target section ########## select Sound target1stSection To Manipulation... 0.01 75 600 Rename... manip1st durInMsec1st = msecDur1st / 1000 durToAdd1st = durInMsec1st * k newLength1st = len1stTargetSel + durToAdd1st paramOfIncrease1st = newLength1st / len1stTargetSel Edit editor Manipulation manip1st Set duration range... 0 10 Add duration point at... 0 paramOfIncrease1st Add duration point at... len1stTargetSel paramOfIncrease1st Publish resynthesis Close select Sound fromManipulationEditor Rename... lengthened1stTargetSection for i to numOfRepetition2nd # 2nd target section ########## select Sound target2ndSection To Manipulation... 0.01 75 600 Rename... manip2nd durInMsec2nd = msecDur2nd / 1000 durToAdd2nd = durInMsec2nd * i newLength2nd = len2ndTargetSel + durToAdd2nd paramOfIncrease2nd = newLength2nd / len2ndTargetSel Edit editor Manipulation manip2nd Set duration range... 0 10 Add duration point at... 0 paramOfIncrease2nd Add duration point at... len2ndTargetSel paramOfIncrease2nd Publish resynthesis Close select Sound fromManipulationEditor Rename... lengthened2ndTargetSection # Put all together select Sound beginSection Copy... newBeginSection select Sound lengthened1stTargetSection Copy... new1stTargetSection select Sound lengthened2ndTargetSection Copy... new2ndTargetSection select Sound endSection Copy... newEndSection select Sound newBeginSection plus Sound new1stTargetSection plus Sound new2ndTargetSection plus Sound newEndSection Concatenate loopSuffix$ = "'k'" + "-" loopSuffix$ = loopSuffix$ + "'i'" Rename... 'loopSuffix$' Play Edit editor Sound 'loopSuffix$' pause Write and proceed to next? Close select Sound 'loopSuffix$' Write to WAV file... 'folderName$'/'folderName$'-'loopSuffix$'.wav select Manipulation manip2nd plus Sound lengthened2ndTargetSection plus Sound newBeginSection plus Sound new1stTargetSection plus Sound new2ndTargetSection plus Sound newEndSection Remove endfor select Manipulation manip1st plus Sound lengthened1stTargetSection Remove endfor select Sound beginSection plus Sound target1stSection plus Sound target2ndSection plus Sound endSection Remove