我有 136 个以数字命名的 wav 文件(1.wav 到 136.wav),以及一个包含 2 秒静音的 wav 文件。我想将它们组合如下,生成其他几个文件:
1 + silence + 2 + silence (copy) + 3
1 + silence + 2 + silence (copy) + 4
2 + silence + 1 + silence (copy) + 3
2 + silence + 1 + silence (copy) + 4
5 + silence + 6 + silence + (copy) + 7
5 + silence + 6 + silence + (copy) + 8
6 + silence + 5 + silence + (copy) + 7
6 + silence + 5 + silence + (copy) + 8
我有下面的脚本,它将文件组合如下:
1 + silence + 2 + silence + (copy) + 1 (copy)
1 + silence + 2 + silence + (copy) + 2 (copy)
2 + silence + 1 + silence + (copy) + 1 (copy)
2 + silence + 1 + silence + (copy) + 1 (copy)
3 + silence + 4 + silence + (copy) + 2 (copy)
3 + silence + 4 + silence + (copy) + 3 (copy)
4 + silence + 3 + silence + (copy) + 3 (copy)
4 + silence + 3 + silence + (copy) + 4 (copy)
str = Create Strings as file list... soundlist 'directory$'/*.wav
num_file = Get number of strings
#writeInfoLine: num_file
#Copy... silence2
for i to num_file
selectObject: str
fileName$ = Get string: i
#writeInfoLine: fileName$
n_fn$ = fileName$
num_c = number(n_fn$ - ".wav")
n_sound_file$ = string$(num_c+1) + ".wav"
if num_c mod 2 == 1
cp_f1$ = fileName$ - ".wav" + "cp"
cp_f2$ = n_sound_file$ - ".wav" + "cp"
cp_sil1$ = "sil1"
f_file$ = "Sound " + fileName$ - ".wav"
s_file$ = "Sound " + n_sound_file$ - ".wav"
f_file2$ = "Sound " + cp_f1$
s_file2$ = "Sound " + cp_f2$
sil_file$ = "Sound " + "silence"
sil_file2$ = "Sound " + "sil1"
writeInfoLine: cp_f1$
new_f1$ = "Sound " + f_file$ + "_sil_" + s_file$ + "_sil_" + f_file$+".wav"
new_f2$ = "Sound " + f_file$ + "_sil_" + s_file$ + "_sil_" + s_file$ + ".wav"
new_f3$ = "Sound " + s_file$ + "_sil_" + f_file$ + "_sil_" + f_file$ + ".wav"
new_f4$ = "Sound " + s_file$ + "_sil_" + f_file$ + "_sil_" + s_file$ + ".wav"
#########
Read from file: directory$+ "/" + fileName$
Read from file: directory$+ "/" + "silence.wav"
Read from file: directory$+ "/" + n_sound_file$
selectObject: sil_file$
Copy... sil1
selectObject: f_file$
Copy... 'cp_f1$'
selectObject: f_file$
plusObject: sil_file$
plusObject: s_file$
plusObject: sil_file2$
plusObject: f_file2$
Concatenate
Save as WAV file... 'directory$'/'new_f1$'
removeObject: f_file$, sil_file$,sil_file2$,f_file2$
#########
Read from file: directory$+ "/" + fileName$
Read from file: directory$+ "/" + "silence.wav"
Read from file: directory$+ "/" + n_sound_file$
selectObject: sil_file$
Copy... sil1
selectObject: s_file$
Copy... 'cp_f2$'
selectObject: f_file$
plusObject: sil_file$
plusObject: s_file$
plusObject: sil_file2$
plusObject: s_file2$
Concatenate
Save as WAV file... 'directory$'/'new_f2$'
removeObject: f_file$, sil_file$,sil_file2$,s_file2$
#####
Read from file: directory$+ "/" + n_sound_file$
Read from file: directory$+ "/" + "silence.wav"
Read from file: directory$+ "/" + fileName$
selectObject: sil_file$
Copy... sil1
selectObject: s_file$
Copy... 'cp_f2$'
selectObject: s_file$
plusObject: sil_file$
plusObject: f_file$
plusObject: sil_file2$
plusObject: s_file2$
Concatenate
Save as WAV file... 'directory$'/'new_f3$'
removeObject: s_file$, sil_file$,sil_file2$,s_file2$
####
Read from file: directory$+ "/" + n_sound_file$
Read from file: directory$+ "/" + "silence.wav"
Read from file: directory$+ "/" + fileName$
selectObject: sil_file$
Copy... sil1
selectObject: f_file$
Copy... 'cp_f1$'
selectObject: s_file$
plusObject: sil_file$
plusObject: f_file$
plusObject: sil_file2$
plusObject: f_file2$
Concatenate
Save as WAV file... 'directory$'/'new_f4$'
endif
endfor
select all
Remove
到目前为止,我的脚本将文件划分为名为奇数和偶数的文件。就我目前的目的而言,算法会更复杂。如果我能得到一些帮助,我将不胜感激!