speech-scoring/test_siamese.py

25 lines
840 B
Python
Raw Normal View History

from speech_siamese import siamese_model
from record_mic_speech import record_spectrogram
from importlib import reload
import speech_data
reload(speech_data)
from speech_data import create_test_pair,get_word_pairs_data
import numpy as np
2017-10-31 12:11:02 +00:00
from keras.utils import to_categorical
model = siamese_model((15, 1654))
model.load_weights('./models/siamese_speech_model-final.h5')
2017-10-26 07:18:31 +00:00
def predict_recording_with(m,sample_size=15):
spec1 = record_spectrogram(n_sec=1.4)
spec2 = record_spectrogram(n_sec=1.4)
inp = create_test_pair(spec1,spec2,sample_size)
return m.predict([inp[:, 0], inp[:, 1]])
2017-11-02 07:44:59 +00:00
while(True):
print(predict_recording_with(model))
2017-10-26 07:18:31 +00:00
2017-11-02 07:44:59 +00:00
# sunflower_data,sunflower_result = get_word_pairs_data('sweater',15)
# print(np.argmax(model.predict([sunflower_data[:, 0], sunflower_data[:, 1]]),axis=1))
# print(sunflower_result)