-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconcat_multiple_files
79 lines (60 loc) · 2.03 KB
/
concat_multiple_files
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
##################
# Concat multiple files (three files as default)
#
# required input: sound files, a list with a header containing filename1, filename2, filename3, outputname.
#
##################
form Concatenate sound triads from table
comment Give the directory of the sound files:
sentence soundDir C:\
comment Give the directory where concatenated sound files will be saved:
sentence saveDir C:\
comment Give the name of the tab-separated input text file:
word inputTable C:\table1.txt
comment Specify the silence duration in seconds:
positive silenceDur 0.5
endform
# remove any objects open in object window
select all
numberOfSelectedObjects = numberOfSelected ()
if numberOfSelectedObjects > 0
Remove
endif
# read in table; first row will be treated as headers
Read Table from tab-separated file... 'inputTable$'
Rename... table
select Table table
# get number of rows in table
numRows = Get number of rows
for i to numRows
# get names of sound files and name of final concatenated file
filename1$ = Table_table$ [i, 1]
filename2$ = Table_table$ [i, 2]
filename3$ = Table_table$ [i, 3]
concatname$ = Table_table$ [i, 4]
# open 1st sound file
Read from file... 'soundDir$''filename1$'.wav
#get sampling frequency of sound and create silence based on that
sampling_freq = Get sampling frequency
silence = Create Sound from formula... silence Mono 0 silenceDur sampling_freq 0
silenceOne$ = selected$("Sound")
# open 2nd sound file
Read from file... 'soundDir$''filename2$'.wav
# create copy of silence
select Sound 'silenceOne$'
silenceTwo = Copy: silenceOne$
# open 3rd sound file
Read from file... 'soundDir$''filename3$'.wav
# now concatenate all three sound files with pauses in between
select all
minus Table table
Concatenate
# save concatenated sounds to wav file
Write to WAV file... 'saveDir$''concatname$'.wav
select all
minus Table table
Remove
endfor
select all
Remove
writeInfoLine: "Successfully created!"