# normalizeAverageIntensity.praat form Parameters word inputFolder s5.ISeeTheMoonShining comment New folder with "-normalized" suffix to be created endform outputFolder$ = inputFolder$ + "-normalized" system_nocheck mkdir 'outputFolder$' Create Strings as file list... fileListObj 'inputFolder$'/*.wav numFiles = Get number of strings pause 'numFiles' files. Calculate mean intensity? # Check the intensity of all files in the folder sumdB = 0 #maxdB = 0 for iFile to numFiles select Strings fileListObj fileName$ = Get string... iFile Read from file... 'inputFolder$'/'fileName$' currentdB = Get intensity (dB) # # Check for maximum # if currentdB > maxdB # maxdB = currentdB # maxFile$ = fileName$ # endif sumdB = sumdB + currentdB Remove endfor # Calculate the average intensity averagedB = sumdB/numFiles pause Average intensity is 'averagedB:0' dB. Proceed with normalization? # Do the normalization for i to numFiles select Strings fileListObj soundName$ = Get string... i prefix$ = soundName$ - ".wav" tgName$ = prefix$ + ".TextGrid" Read from file... 'inputFolder$'/'tgName$' Read from file... 'inputFolder$'/'soundName$' Scale intensity... averagedB Save as WAV file... 'outputFolder$'/'soundName$' filedelete 'inputFolder$'/'soundName$' Remove select TextGrid 'prefix$' Save as text file... 'outputFolder$'/'tgName$' filedelete 'inputFolder$'/'tgName$' Remove endfor select Strings fileListObj Remove