Example #1
0
    def tttest_Bringup_voicecode_user_switching(self):
    
        user, dummy = natlink.getCurrentUser()
        if user == 'VoiceCode':
            mes = ['active user is: %s'% user, '',
                   'Cannot test voicecode_user_switching to VoiceCode again', '', 
                   'Please start test with another user being active.']
            actions.Message(mes)
            self.fail("start test with a user profile NOT being VoiceCode")
            

        preserveApps = ['emacs']  #ther adepps are killed after the test
        apps = ['voicecode', 'notepad']
        if not self.doTestBringupApplications(apps, preserveApps, prompt="test_Bringup_voicecode_user_switching"):
            print('test_Bringup_voicecode_user_switching skipped halfway')
            return
        newUser, dummy = natlink.getCurrentUser()
        self.assert_equal('VoiceCode', newUser, "user name should be switched to 'VoiceCode'")
        if user == newUser:
            mes = ['cannot test voicecode user coming from another user',
                   'start test from another user as "VoiceCode"']
            actions.Message(mes)

        natlink.openUser(user)
        newUser, dummy = natlink.getCurrentUser()
        self.assert_equal(user, newUser, "user name should be switched to '%s'\n"
                          "in order to be able to test the user switching part of this test"% user)
        self.doTestBringupApplications(apps, preserveApps, prompt=0)
        newUser, dummy = natlink.getCurrentUser()
        self.assert_equal('VoiceCode', newUser, "user name should be switched to 'VoiceCode', also the second time of testing")
Example #2
0
 def gotResults_openuser(self,words,fullResults):
     user = self.getFromInifile(words[-1], 'users')
     print 'user: %s'% user
     try:
         natlink.openUser(user)
     except natlink.UnknownName:
         print 'cannot open user "%s", unknown name'% user
Example #3
0
 def gotResults_openuser(self, words, fullResults):
     user = self.getFromInifile(words[-1], 'users')
     print 'user: %s' % user
     try:
         natlink.openUser(user)
     except natlink.UnknownName:
         print 'cannot open user "%s", unknown name' % user
Example #4
0
def openUser(user_name):
    """Open a user
        
    **INPUTS**
        
    *STR* user_name -- Name of the user to be opened.

    **OUTPUTS**
        
    *none* -- 
    """

    natlink.openUser(user_name)
Example #5
0
def openUser(user_name):

    """Open a user
        
    **INPUTS**
        
    *STR* user_name -- Name of the user to be opened.

    **OUTPUTS**
        
    *none* -- 
    """
    
    natlink.openUser(user_name)
Example #6
0
def createNewUser(userName,baseModel,baseTopic):
    if natlink.getCurrentUser()[0] == userName:
        print 'Training existing user:'******'Creating user:'******'  using baseModel:',baseModel
        else:
            print '  using baseModel: (default)'
        if baseTopic:
            print '  using baseTopic:',baseTopic
        else:
            print '  using baseTopic: (default)'
        natlink.createUser(userName,baseModel,baseTopic)
        natlink.openUser(userName)
    if natlink.getUserTraining():
        print 'Error: user is already at least partially trained.'
        raise TrainingError,'user is trained'
Example #7
0
def createNewUser(userName, baseModel, baseTopic):
    if natlink.getCurrentUser()[0] == userName:
        print 'Training existing user:'******'Creating user:'******'  using baseModel:', baseModel
        else:
            print '  using baseModel: (default)'
        if baseTopic:
            print '  using baseTopic:', baseTopic
        else:
            print '  using baseTopic: (default)'
        natlink.createUser(userName, baseModel, baseTopic)
        natlink.openUser(userName)
    if natlink.getUserTraining():
        print 'Error: user is already at least partially trained.'
        raise TrainingError, 'user is trained'
Example #8
0
class DragonRule(MappingRule):
    mapping = {
        "(go-to-sleep | snore | mic-sleep)":
        Function(lambda: natlink.setMicState("sleeping")),
        "(lock-Dragon|turn-mic-off)":
        Function(lambda: natlink.setMicState("off")),
        "german profile":
        Function(
            lambda: natlink.saveUser() + natlink.openUser("Codebold german")),
        "englisches Profil":
        Function(lambda: natlink.saveUser() + natlink.openUser("Codebold")),
        "reload grammar[s]":
        Function(lambda: updateAllGrammars()),
        "reload <grammar>":
        GrammarUpdate(),
        "como":
        Function(lambda: natlink.recognitionMimic(
            ["switch", "to", "command", "mode"])),
        "diemo":
        Function(
            lambda: natlink.recognitionMimic(["start", "dictation", "mode"])),
        "nomo":
        Function(lambda: natlink.recognitionMimic(["normal", "mode", "on"])),
        "sleemo":
        Function(lambda: natlink.recognitionMimic(["go", "to", "sleep"])),
        "dictation":
        Function(
            lambda: natlink.recognitionMimic(["show", "dictation", "box"])),
        "dictox":
        Function(lambda: natlink.recognitionMimic(["normal", "mode", "on"])) +
        Function(
            lambda: natlink.recognitionMimic(["show", "dictation", "box"])),
        "transfox":
        Function(lambda: natlink.recognitionMimic(["click", "transfer"])) +
        Function(lambda: natlink.recognitionMimic(["command", "mode", "on"])),
        "blitz NatLink":
        Function(blitz_natlink_status),
        "show NatLink":
        Function(show_natlink_status)
    }
    extras = [chc_base.grammar]
 def tearDown(self):
     endUser = natlink.getCurrentUser()[0]
     if self.startUser != endUser:
         print 'reopen user: %s' % self.startUser
         natlink.openUser(self.startUser)
     actions.debugActions(0)
    grammars[grammar_name].setExclusive(exclusive)
    return "done"


@rpc
def activate(grammar_name, rule_name):
    grammars[grammar_name].activate(rule_name, 0)
    return "done"


@rpc
def deactivate(grammar_name, rule_name):
    grammars[grammar_name].deactivate(rule_name)
    return "done"


#@rpc
#def updateList(grammar_name, list_name, elements): Pass

try:
    print "loading"
    natlink.natConnect(1)
    natlink.openUser("Michael")
    natlink.setMicState("on")
    natlink.setTimerCallback(drainRequests, 100)
    natlink.waitForSpeech(0)
except Exception as e:
    print e
finally:
    shutdown()