forked from ah450/proteus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.tmpl
More file actions
28 lines (22 loc) · 679 Bytes
/
python.tmpl
File metadata and controls
28 lines (22 loc) · 679 Bytes
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
FILE recog.py BEGIN
from ctypes import *
class Recognizer(object):
def __init__(self, lmPath):
gramPath = lmPath + '/THE_GRAMMAR'
dictPath = lmPath + '/THE_DICT'
self.word_id_dict = dict()
self.libprot = cdll.LoadLibrary("./libproteus.so")
#Now we populate the dictionary
EXPAND_ME_BEGIN
self.word_id_dict['COMMAND_EX'] = 'ID_EX'
EXPAND_ME_END
#initialize library
initFunc = self.libprot.prot_init
initFunc.restype = c_void_p
self.handle = initFunc(gramPath, dictPath)
self.recFunc = self.libprot.recog_word
self.recFunc.restype = c_char_p
def recog_word(self):
recognized = self.libprot.recog_word(self.handle)
return recognized
FILE END