-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
39 lines (32 loc) · 995 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python2
from __future__ import division
import subprocess
from reco import RecoBlock
recognizer = RecoBlock("train_data")
def menu():
global recognizer
# print menu
print "\n"
menu_str = """Choose an option:
1) Train the recognizer again
2) Test the trained recognizer
3) Exit
"""
print menu_str
# get the user's choice now
choice = int(raw_input())
if choice == 1:
# train a new recognizer
recognizer = Recoblock("train_data")
elif choice == 2:
# record a voice now and find out the speaker
subprocess.call(["arecord", "-d", "5s", "-r", "48000", "_melcache/__test.wav"])
spkr = recognizer.predict("_melcache/__test.wav")
print "The speker must be: %s" % spkr
elif choice == 3:
exit(0)
else:
print "Invalid choicec.\n\n"
menu()
if __name__ == "__main__":
menu()