-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
77 lines (55 loc) · 1.39 KB
/
test.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
# encoding: utf-8
"""
untitled.py
Created by Tim on 2011-07-05.
Copyright (c) 2011 __MyCompanyName__. All rights reserved.
"""
import sys
import getopt
from histoClassifier import *
help_message = '''
The help message goes here.
'''
class Usage(Exception):
def __init__(self, msg):
self.msg = msg
def main(argv=None):
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "ho:v", ["help", "output="])
except getopt.error, msg:
raise Usage(msg)
# option processing
for option, value in opts:
if option == "-v":
verbose = True
if option in ("-h", "--help"):
raise Usage(help_message)
if option in ("-o", "--output"):
output = value
except Usage, err:
print >> sys.stderr, sys.argv[0].split("/")[-1] + ": " + str(err.msg)
print >> sys.stderr, "\t for help use --help"
return 2
if len(args)>1:
chordDetector = histoClassifier('/Users/Tim/Documents/Music Research/chords_all')
result = chordDetector.classify([int(n) for n in args])
k = result.keys()
k.sort()
print result[k[-1]]
# else:
# print "more notes please"
if __name__ == "__main__":
sys.exit(main())
# convert from letter to numbers
nlist = []
for c in notelist:
nlist += [noteLetters[c.lower()]]
result = keyDetector.classify(nlist)
# print highest probability results
k = result.keys()
k.sort()
print result[k[-1]]