2017-10-25 11:22:45 +00:00
|
|
|
from speech_siamese import siamese_model
|
2017-10-25 10:08:03 +00:00
|
|
|
from record_mic_speech import record_spectrogram
|
2017-10-25 11:22:45 +00:00
|
|
|
from importlib import reload
|
2017-11-03 08:49:19 +00:00
|
|
|
# import speech_data
|
|
|
|
|
# reload(speech_data)
|
|
|
|
|
from speech_data import create_test_pair,get_word_pairs_data,speech_data
|
2017-10-25 11:22:45 +00:00
|
|
|
import numpy as np
|
2017-10-25 10:08:03 +00:00
|
|
|
|
2017-10-25 11:22:45 +00:00
|
|
|
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-03 08:49:19 +00:00
|
|
|
# while(True):
|
|
|
|
|
# print(predict_recording_with(model))
|
2017-10-26 07:18:31 +00:00
|
|
|
|
2017-11-03 08:49:19 +00:00
|
|
|
|
|
|
|
|
def test_with(audio_group):
|
|
|
|
|
X,Y = speech_data(audio_group)
|
|
|
|
|
print(np.argmax(model.predict([X[:, 0], X[:, 1]]),axis=1))
|
|
|
|
|
print(Y.astype(np.int8))
|
|
|
|
|
|
|
|
|
|
test_with('rand_edu')
|
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)
|