# This praat script produces temporally segmented speech # cf. Huggins, A. W. F. (1972) Temporally segmented speech, Perception and Psychophysics, 18(2), 149-157. # written by Matt Davis (matt.davis@mrc-cbu.cam.ac.uk) - 24.10.2000 # # three parameters to set: # gap_size = duration of gap between adjacent segments of speech # speech_chunk = duration of each chunk of speech # ramp_time = period over which speech chunks are ramped at onset and offset # (helps prevents clicks and pops) # ################################################# # set parameters in the form ################################################# form Generate temporally segmented speech (cf. Huggins, 1972) positive gap_size_(seconds) 0.2 positive speech_chunk_(seconds) 0.2 positive ramp_time_(seconds) 0.01 endform ################################################# # or uncomment to always use these values ################################################# #gap_size = 0.2 #speech_chunk = 0.2 #ramp_time = 0.01 ################################################# # script starts here ################################################# fname$ = selected$ ("Sound", 1 ) oname$ = "Segmented_" + fname$ srate = Get sample rate duration = Get duration # take first chunk and ramp down at end Create Sound... 'oname$' 0 speech_chunk srate self + Sound_'fname$'(x) Formula... if x>('speech_chunk'-'ramp_time') then ((1/'ramp_time')*('speech_chunk'-x)*self) else self fi start = speech_chunk # loop over remaining chunks and gaps repeat # generate silence and chunk of speech, ramp start and end of speech Create Sound... Silence 0 gap_size srate self Create Sound... Chunk 0 speech_chunk srate self + Sound_'fname$'(x+'start') Formula... if x<'ramp_time' then (1/'ramp_time')*x*self else if x>('speech_chunk'-'ramp_time') then (1/'ramp_time')*('speech_chunk'-x)*self else self fi fi # concatenate previous file, silence and new chunk select Sound 'oname$' plus Sound Silence plus Sound Chunk Concatenate # remove junk, rename then remove again select Sound Chunk plus Sound Silence plus Sound 'oname$' Remove select Sound chain Copy... 'oname$' select Sound chain Remove # increment position start = start + speech_chunk until (start + speech_chunk) >= duration # make silence and final_chunk, ramp onset then append Create Sound... Silence 0 gap_size srate self final_length = duration - start Create Sound... Final_Chunk 0 final_length srate self + Sound_'fname$'(x+'start') Formula... if x<'ramp_time' then (1/'ramp_time')*x*self else self fi select Sound 'oname$' plus Sound Silence plus Sound Final_Chunk Concatenate select Sound Final_Chunk plus Sound 'oname$' plus Sound Silence Remove select Sound chain Copy... 'oname$' select Sound chain Remove