Anyone can please help me with a tensorflow question ?
I have this database of audio files, and i computed them the coresponding mel spectograms.
The audio files have different lenghts, so consequently the mel spectograms will have different shapes.
Finally i'm adding all these mel spectograms in a list called " mels "
I'm trying to convert the "mels" list to a tensor, so i can add it to my tf.data.Dataset variable, but it keeps getting me the error that a non rectulangar shape can not be converted to a tensor.
So I tried to convert it to tensor using ragged tensors, but it takes waaay to long to convert the whole mel list to a ragged tensor.
I tried to convert a smaller length list ( only having 3 mel spectograms ) and it took like 30 seconds to finish the convertion to a ragged tensor
So for a list having like over 200 mel spectograms, would take like half an hour or something
which is not ok.
Is there a way to convert this mel list to a tensor ?
Here's the small part of the code in case I've done some silly mistakes
###########
def _load_spectrograms(fpaths):
fnames = []
mels = []
mags = []
for f in fpaths:
fname = os.path.basename(f)
mel = "mels/{}".format(fname.replace("wav", "npy"))
mag = "mags/{}".format(fname.replace("wav", "npy"))
mel = np.load(mel)
mag = np.load(mag)
# mel = tf.convert_to_tensor(mel)
# mag = tf.convert_to_tensor(mag)
# mel.set_shape((None, hp.n_mels * hp.r))
# mag.set_shape((None, hp.n_fft // 2 + 1))
fnames.append(fname)
mels.append(mel)
mags.append(mag)
return fnames, mels, mags
fnames, mels, mags = _load_spectrograms(fpaths)
mels = tf.ragged.constant(mels)
mags = tf.ragged.constant(mags)
########
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…