{sound1:10000, sound2:10001, ect...}
到目前为止,我已经想出了一种增加沉默的方法:
def change_speed(seconds):
'''modifies the metronome beat to loop at different speeds. This is done by creating a new wav file.'''
#original wav file is 0.1 seconds long, so subtract that from time added
seconds-=0.1
#read the original wav file
original = scipy.io.wavfile.read('Downloads\\sounds\\metronome_original.wav')
#use sample rate of the original file (should be 44100) to create a new block of silence
add_secs = np.array([[0]]*round(original[0]*seconds))
add_secs.dtype='int16'
#concatenate new block to original
new = np.concatenate((original[1], add_secs))
scipy.io.wavfile.write('Downloads\\sounds\\metronome.wav', original[0], new)
[[0,0,1,1,2,0], [0,0,0,3,2,1]]
一个wav文件?
更新:
更具体地说,我正在尝试合并两个在播放时间重叠的音频样本,比如一个DJ在一首歌播放完之前就开始播放另一首歌。有没有办法在python中生成整数或字节数组?