I am building a speech recognition model
after training the model with .wav file (mono)(16000 sampling rate) I tried to test it using a recorded audio the recorded audio's parameter was like the parameter of the audio files which with the model was trained (.wav file) (mono)(16000 sampling rate) and the length is 1 sec
but I got this error
Traceback (most recent call last):
File "Testing.py", line 21, in <module>
print(predict(samples))
File "Testing.py", line 13, in predict
prob=model.predict(audio.reshape(1,8000,1))
ValueError: cannot reshape array of size 15183 into shape (1,8000,1)
this is the code used for testing
model=load_model('/home/moataz-beheta/Desktop/speech/Model/best_model.hdf5')
filepath='/home/moataz-beheta/Desktop/speech/input/Testing'
def predict(audio):
prob=model.predict(audio.reshape(1,8000,1))
index=np.argmax(prob[0])
return classes[index] #return labels
#reading the voice commands
samples, sample_rate = librosa.load(filepath + '/' + 'PTT-20200625-WA0035.wav', sr = 16000)
samples = librosa.resample(samples, sample_rate, 8000)
ipd.Audio(samples,rate=8000)
print(predict(samples))
So, how can I solve it ?