--- /dev/null
+import numpy as np
+import sys
+from keras.models import model_from_json
+
+with open('model.json', 'r') as f:
+ json = f.read()
+
+model = model_from_json(json)
+model.load_weights('./model.hdf5')
+model.compile(
+ loss='binary_crossentropy',
+ optimizer='rmsprop',
+ metrics=['accuracy'])
+
+dat = np.genfromtxt(sys.stdin.buffer, dtype=float, delimiter='\t')
+for i in model.predict(dat, batch_size=32, verbose=0):
+ print(i[0])
FREQUENCY=44100
#FREQUENCY=22050
-rm -rf wav mfcc
-mkdir -p wav mfcc
-i=0
-for f in orig/*.flac; do
- while [ $(jobs -p | wc -l) -ge $MAXPROCS ]; do sleep 1; done
-
- echo $f
- BN="$(echo $f | grep -Po "(?<=/[0-9][0-9]_-_).*(?=\.flac)")"
- NUM="$(printf '%02d' "$i")"
- WAV="wav/$NUM.wav"
- MFCC="mfcc/$NUM.mfcc"
-
- ( echo "Processing $f" &&
- sox "$f" -V1 -c 1 -r $FREQUENCY $WAV &&
- python mfcc.py < "$WAV" > "$MFCC"
- ) &
- i=$((i+1))
-done
-wait
+#rm -rf wav mfcc
+#mkdir -p wav mfcc
+#i=0
+#for f in orig/*.flac; do
+# while [ $(jobs -p | wc -l) -ge $MAXPROCS ]; do sleep 1; done
+#
+# echo $f
+# BN="$(echo $f | grep -Po "(?<=/[0-9][0-9]_-_).*(?=\.flac)")"
+# NUM="$(printf '%02d' "$i")"
+# WAV="wav/$NUM.wav"
+# MFCC="mfcc/$NUM.mfcc"
+#
+# ( echo "Processing $f" &&
+# sox "$f" -V1 -c 1 -r $FREQUENCY $WAV &&
+# python mfcc.py < "$WAV" > "$MFCC"
+# ) &
+# i=$((i+1))
+#done
+#wait
python segment.py
python train.py
python test.py
model.summary()
-dat = np.genfromtxt('test.txt', dtype=float, delimiter='\t')[:, range(1, 14)]
-lab = np.genfromtxt('test.txt', dtype=int, delimiter='\t')[:, 0]
+dat = np.genfromtxt('test.txt', dtype=float, delimiter='\t', usecols=range(1, 14))
+lab = np.genfromtxt('test.txt', dtype=int, delimiter='\t', usecols=[0])
print(model.evaluate(dat, lab, batch_size=32))
model = Sequential()
-model.add(Dense(26, input_shape=(13,), activation='relu'))
+model.add(Dense(2000, input_shape=(13,), activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(
model.summary()
-dat = np.genfromtxt('train.txt', dtype=float, delimiter='\t')[:, range(1, 14)]
-lab = np.genfromtxt('train.txt', dtype=int, delimiter='\t')[:, 0]
+dat = np.genfromtxt('train.txt', dtype=float, delimiter='\t', usecols=range(1, 14))
+lab = np.genfromtxt('train.txt', dtype=int, delimiter='\t', usecols=[0])
model.fit(dat, lab, epochs=10, batch_size=32)