From 7878199718ca38c5e321e13598de46a5dc38ea0e Mon Sep 17 00:00:00 2001 From: Mart Lubbers Date: Sun, 30 Apr 2017 11:55:42 +0200 Subject: [PATCH] update --- predict.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) 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]) -- 2.20.1