Example #1
0
h5fContent = h5py.File(H5_Write, 'w')
train = h5fContent.create_dataset("train",(trainFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
trainLabel = h5fContent.create_dataset("trainLabel",(trainFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
trainAE = h5fContent.create_dataset("trainAE",(trainFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
valid = h5fContent.create_dataset("valid",(validFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
validLabel = h5fContent.create_dataset("validLabel",(validFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
validAE = h5fContent.create_dataset("validAE",(validFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
test = h5fContent.create_dataset("test",(testFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
testLabel = h5fContent.create_dataset("testLabel",(testFrames,numFTBins),chunks=(1,numFTBins),dtype='f')
testAE = h5fContent.create_dataset("testAE",(testFrames,numFTBins),chunks=(1,numFTBins),dtype='f')

for t in np.arange(numMusics):
    #########################################################################
    ## Step 1 - Import Audio and Create Power Spectrogram
    tic = time.time()
    x, fs = AD.audioread(WavFileNames[t])
    Mix = Signal()
    Voice = Signal()
    Song = Signal()
    Voice.x = rs.resample(x[:,1], fs, hfs)
    Song.x = rs.resample(x[:,0], fs, hfs)
    Mix.x = Voice.x + Song.x
    # Spectrogram Dimension - Parm.numBins:2049 X Parm.numFrames:2584 = 5,294,616
    _, Voice.mX, _, _, _, _ = SM.stft(Voice.x, Parm)
    _, Song.mX, _, _, _, _ = SM.stft(Song.x, Parm)
    _, Mix.mX, _, _, _, _ = SM.stft(Mix.x, Parm)
    Voice.mX = np.float32(Voice.mX)
    Song.mX = np.float32(Song.mX)
    Mix.mX = np.float32(Mix.mX)
    PadMin[:,:] = min(Mix.mX.min(0))
    mX = np.concatenate((PadMin,Mix.mX,PadMin),axis=1)
 if t == 35 or t == 36 or t == 42 or t == 43:
     continue
 
 #########################################################################
 ## Step 1 - Import Audio and Create Spectrogram
 tic = time.time()
 if t<50:
     SetStr = 'Test/'
 else:
     SetStr = 'Dev/'
 BassPath = WavDirStr + SetStr + AllNames[t] + '/bass.wav'
 DrumsPath = WavDirStr + SetStr + AllNames[t] + '/drums.wav'
 OtherPath = WavDirStr + SetStr + AllNames[t] + '/other.wav'
 VoicePath = WavDirStr + SetStr + AllNames[t] + '/vocals.wav'
 # Import Audio
 Bassx, _ = AD.audioread(BassPath)
 BassxL = Bassx[:,0]    
 Drumx, _ = AD.audioread(DrumsPath)
 DrumxL = Drumx[:,0]    
 Otherx, _ = AD.audioread(OtherPath)
 OtherxL = Otherx[:,0]    
 Voice.x, _ = AD.audioread(VoicePath)
 Voice.xL = Voice.x[:,0]
 Song.xL = BassxL + DrumxL + OtherxL
 # In Dev Set, also use right channel as Validation
 if t>49:
     BassxR = Bassx[:,1]
     DrumxR = Drumx[:,1]
     OtherxR = Otherx[:,1]
     Voice.xR = Voice.x[:,1]
     Song.xR = BassxR + DrumxR + OtherxR