In [2]:
# Build an exhaustive list of audio files (ranging from 1 to 59) given a base of audio units.
# For example, 42.wav is composed with 40.wav and 2.wav
# Base units = [ 0, 1, and1, 2:16, 20, 30, 40, 50 ] have to be located in pathUnit.
# Final files are generated in pathFull.
pathUnit = '/myPathUnit/'
pathFull = '/myPathFull/'
tSet = range(17,60)
tSet = [t for t in tSet if t%10 != 0] # remove multiple of ten
# Compose audio files (for ex 42) using base units (40 and 2)
from subprocess import run
for t in tSet:
(d,u) = divmod(t,10)
run(['sox',pathUnit+str(d)+'0.ogg',pathUnit+str(u)+'.ogg',pathFull+str(t)+'.ogg'])
# Pool files
import glob, shutil, os
for f in glob.iglob(os.path.join(pathUnit,"*.ogg")):
shutil.copy(f,pathFull)
os.remove(pathFull+'1.ogg')
os.rename(pathFull+'01.ogg', pathFull+'1.ogg')