I am looking to combine 10 audio samples in various manners (format - wav probably, but this can be changed to any format as they will be pre-recorded).
from pydub import AudioSegment sounds = [] sound1 = AudioSegment.from_wav("Dropbox/PIREAD/1.wav") sound2 = AudioSegment.from_wav("Dropbox/PIREAD/2.wav") sound3 = AudioSegment.from_wav("Dropbox/PIREAD/3.wav") sound4 = AudioSegment.from_wav("Dropbox/PIREAD/4.wav") sound5 = AudioSegment.from_wav("Dropbox/PIREAD/5.wav") sound6 = AudioSegment.from_wav("Dropbox/PIREAD/6.wav") sound7 = AudioSegment.from_wav("Dropbox/PIREAD/7.wav") sound8 = AudioSegment.from_wav("Dropbox/PIREAD/8.wav") sound9 = AudioSegment.from_wav("Dropbox/PIREAD/9.wav") sound0 = AudioSegment.from_wav("Dropbox/PIREAD/0.wav") sounds=[sound1,sound2,sound3,sound4,sound5,sound6,sound7,sound8,sound9,sound0] combined_sounds = AudioSegment.empty() for x in range(10): for y in range(10): combined_sounds += sounds[y] combined_sounds.export("Dropbox/PIREAD/joinedFile.wav", format="wav") This is literally me reading the numbers 0-9 and assembling them into one overall wav file.
It works - but it is slow once the loop is extended x=100, x=1000.
Q: How can I speed things up?
The actual order of the numbers will be read from a text$ - for example "354224848179261915075" which happens to be the 100th Fibonacci number.
Cheers Glen