Skip to content
Permalink
Browse files Browse the repository at this point in the history
Improved File Segmenter
It should now be less vulnerable to certain characters in Textgrids (e.g. /) crashing everything.
  • Loading branch information
stylerw committed Nov 24, 2021
1 parent 949cf72 commit 0cad44a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions file_segmenter.praat
Expand Up @@ -27,7 +27,7 @@

form Chopping long sound files
comment Specify which tier in the TextGrid you want to segment by:
integer tier_number 2
integer tier_number 3
comment Sound file extension:
optionmenu file_type: 2
option .aiff
Expand Down Expand Up @@ -68,18 +68,23 @@ for j from 1 to number_of_files
select Sound 'soundname$'
Extract part: start, end, "rectangular", 1, "no"
if namebase$ <> ""
out_filename$ = "'out_dir$''namebase$'_'seg_label$'"
writename$ = "'namebase$'_'seg_label$'"
else
out_filename$ = "'out_dir$''soundname$'_'seg_label$'"
writename$ = "'soundname$'_'seg_label$'"
endif
# Although you should use ASCII when making textgrids, this bit removes some instacrashes
writename$ = replace$ (writename$, " ", "_", 0)
writename$ = replace$ (writename$, "/", "_", 0)
out_filename$ = "'out_dir$''writename$'"
# initialize anti-collision counter.
aff = 1
aff = 1
name$ = "'out_filename$'_'aff'"
while fileReadable ("'name$'.wav")
#out_filename$ = "'out_dir$''soundname$'-'seg_label$'-'k'"

#writeInfo: name$
while fileReadable ("'name$'.wav")
aff = aff + 1
name$ = "'out_filename$'_'aff'"
endwhile
endwhile
Write to WAV file... 'name$'.wav
select TextGrid 'soundname$'
Extract part... 'start' 'end' no
Expand Down
2 changes: 1 addition & 1 deletion nasal_earbud_extract.praat
Expand Up @@ -245,7 +245,7 @@ for ifile to number_files
vwlpct = ((timepoint-intstart)/intdur)*100

result_row$ = "'soundname$'" + tab$ + "'point'" + tab$ + "'vwlpct:2'" + tab$ + "'naspasc:10'" + tab$ + "'orpasc:10'" + tab$ + "'percnas:5'" + tab$ + "'timepoint:4'" + newline$
#fileappend "'resultfile$'" 'result_row$'
fileappend "'resultfile$'" 'result_row$'

endfor
else
Expand Down

0 comments on commit 0cad44a

Please sign in to comment.