-
Notifications
You must be signed in to change notification settings - Fork 0
/
communicator_vcl.py
85 lines (74 loc) · 2.41 KB
/
communicator_vcl.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
78
79
80
81
82
83
84
85
# NatLink macro definitions for NaturallySpeaking
# coding: latin-1
# Generated by vcl2py 2.8.1I+, Fri Oct 31 17:34:49 2014
import natlink
from natlinkutils import *
from VocolaUtils import *
class ThisGrammar(GrammarBase):
gramSpec = """
<1> = 'call first contact' ;
<any> = <1>;
<sequence> exported = <any>;
"""
def initialize(self):
self.load(self.gramSpec)
self.currentModule = ("","",0)
self.ruleSet1 = ['sequence']
def gotBegin(self,moduleInfo):
# Return if wrong application
window = matchWindow(moduleInfo,'communicator','')
if not window: return None
self.firstWord = 0
# Return if same window and title as before
if moduleInfo == self.currentModule: return None
self.currentModule = moduleInfo
self.deactivateAll()
title = string.lower(moduleInfo[1])
if string.find(title,'') >= 0:
for rule in self.ruleSet1:
try:
self.activate(rule,window)
except natlink.BadWindow:
pass
def convert_number_word(self, word):
if word == 'zero':
return '0'
elif word == 'one':
return '1'
elif word == 'two':
return '2'
elif word == 'three':
return '3'
elif word == 'four':
return '4'
elif word == 'five':
return '5'
elif word == 'six':
return '6'
elif word == 'seven':
return '7'
elif word == 'eight':
return '8'
elif word == 'nine':
return '9'
else:
return word
# 'call first contact'
def gotResults_1(self, words, fullResults):
if self.firstWord<0:
return
try:
top_buffer = ''
top_buffer += '{Tab_5}{Enter}'
top_buffer = do_flush(False, top_buffer);
self.firstWord += 1
if len(words) > 1: self.gotResults_1(words[1:], fullResults)
except Exception, e:
handle_error('communicator.vcl', 5, '\'call first contact\'', e)
self.firstWord = -1
thisGrammar = ThisGrammar()
thisGrammar.initialize()
def unload():
global thisGrammar
if thisGrammar: thisGrammar.unload()
thisGrammar = None