-
Notifications
You must be signed in to change notification settings - Fork 24
/
change_sample_rate_of_sound_files.praat
47 lines (44 loc) · 1.57 KB
/
change_sample_rate_of_sound_files.praat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This Praat script will change the sample rate of all sound files in a given directory
# and save AIFF files with the new rate to another directory.
# (See the Praat manual for details on resampling.)
#
# This script is distributed under the GNU General Public License.
# Copyright 29.10.2003 Mietta Lennes
form Change sample rate in sound files
sentence Sound_file_extension .aif
comment Directory path of input files:
text input_directory C:\tmp\
comment Directory path of resampled files (old files will be overwritten!):
text output_directory C:\tmp\resampled\
optionmenu Output_format: 1
option AIFF
option WAV
positive New_sample_rate_(Hz) 22050
positive Precision_(samples) 50
comment (See the Praat manual for details on resampling.)
endform
Create Strings as file list... list 'input_directory$'*'sound_file_extension$'
numberOfFiles = Get number of strings
for ifile to numberOfFiles
select Strings list
sound$ = Get string... ifile
Read from file... 'input_directory$''sound$'
objectname$ = selected$ ("Sound", 1)
oldrate = Get sample rate
if oldrate <> new_sample_rate
printline Resampling 'input_directory$''sound$' to 'new_sample_rate' Hz...
Resample... new_sample_rate precision
else
printline Sample rate of 'input_directory$''sound$' is already 'new_sample_rate' Hz, copying this file...
endif
if output_format$ = "AIFF"
Write to AIFF file... 'output_directory$''objectname$'.aif
else
Write to WAV file... 'output_directory$''objectname$'.wav
endif
Remove
select Sound 'objectname$'
Remove
endfor
select Strings list
Remove