From: Mart Lubbers Date: Sun, 30 Apr 2017 09:55:42 +0000 (+0200) Subject: update X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=7878199718ca38c5e321e13598de46a5dc38ea0e;p=asr1617data.git update --- diff --git a/predict.py b/predict.py index f2adb8e..962b9fd 100644 --- a/predict.py +++ b/predict.py @@ -1,17 +1,26 @@ import numpy as np import sys + +import scipy.io.wavfile as wav +import numpy as np +from python_speech_featuresimport mfcc + from keras.models import model_from_json -with open('model.json', 'r') as f: - json = f.read() +modelfile = sys.argv[1] +hdf5file = '{}.hdf5'.format(modelfile[-4:]) +with open(modelfile, 'r') as f: + json = f.read() model = model_from_json(json) -model.load_weights('./model.hdf5') +model.load_weights(hdf5file) + model.compile( loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy']) -dat = np.genfromtxt(sys.stdin.buffer, dtype=float, delimiter='\t') +(rate, sig) = wav.read(sys.stdin.buffer) +data = mfcc(sig, rate, winlen for i in model.predict(dat, batch_size=32, verbose=0): print(i[0])