Skip to content

Instantly share code, notes, and snippets.

@GiovanniBalestrieri
Last active October 26, 2017 13:53
Show Gist options
  • Save GiovanniBalestrieri/5e067f05e5d30021754ba398b6b0d3ba to your computer and use it in GitHub Desktop.
Save GiovanniBalestrieri/5e067f05e5d30021754ba398b6b0d3ba to your computer and use it in GitHub Desktop.
Adding sounds to a recorded wav file in Python
import numpy as np
from scikits.audiolab import wavread, wavwrite
data1, fs1, enc1 = wavread("finevite112.wav")
data2, fs2, enc2 = wavread("machine1.wav")
assert fs1 == fs2
assert enc1 == enc2
data2ok = np.split(data2,[len(data2)//2 - len(data1)//2, len(data2)//2 + len(data1)//2+1])[1]
for i in range(2,6):
result = 1 * data1 + i/10.0 * data2ok
wavwrite(result, str(i)+'result.wav',fs1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment