making an audio to audio model in keras

Viewed 188

I have a dataset of two types of audios in wav format. I am trying to train the keras model in such a fashion that input which is audio 'a' gets converted to output which will be audio 'b'. Currently I am doing it like this:

X_train,X_test,y_train,y_test=get_audio_sets()  # returns wav files' numpy arrays of same size for training and validation

input_ = Input(shape=(192000,1))   #input layer

x=LSTM(64)(input_)  

x=Dense(512, name='dense1')(x)
x=LeakyReLU()(x)

# the audio is very poor here, training is quite slow and I think having 192000 output units is not a good idea
output=Dense(192000, activation='tanh')(x)  # range is from -1,1

model = Model(input_, output)

adam=Adam(lr=0.0001)

model.compile(optimizer=adam, loss='mae')  #compile the model


model.summary()

from keras.callbacks import TensorBoard

#early stoping is used to prevent overfitting
es=keras.callbacks.EarlyStopping(monitor='val_loss', min_delta=0, patience=10, verbose=0, mode='auto',baseline=None, restore_best_weights=True)

#train the model
model.fit(X_train, y_train,
                epochs=10,
                batch_size=32,
                shuffle=False,
                validation_data=(X_test, y_test),
                callbacks=[es])

All the features and labels have the same shape, hence it can be trained in an end to end manner. But I am not sure that having 192000 units in output is a good solution. Maybe a seq2seq model will be better here? But I am struggling to change code in keras for this problem. Can someone kindly help me in making a keras model which can be trained by giving audio as an input feature and another audio as an output? The audios can be of English to German set, French to Italian, Noisy audio to clear audio, etc. Any help will be highly appreciated!

1 Answers

Audio/Speech synthesis is pretty complicated.

  1. You can look into wavenet (fast-wavenet) architecture which does something similar but optimized.

  2. I would suggest, choose an intermediate representation. The audio contains most of its information in the frequency domain rather than time.

You can design a model which takes audio -> converts to mel-spectogram -> passes to model -> gets the mel-spectogram -> uses inverse operation + griffin-lim to get the audio.

librosa is cool library to look at : https://librosa.github.io/librosa/generated/librosa.feature.melspectrogram.html

Related