Esempio n. 1
0
 def write(self, text):
     if text.find('\x00') >= 0:
         text = text.replace('\x00', '')
         text = "===Warning, text contains null bytes==\n" + text
     if type(text) == types.UnicodeType:
         text = text.encode('cp1252')
     natlink.displayText(text, 0)
Esempio n. 2
0
 def log(self, t, doPlaystring=None):
     # displayTest seems not to work:
     natlink.displayText(t, 0)
     if doPlaystring:
         natlink.playString(t+'\n')
     # do the global log function:
     log(t)
Esempio n. 3
0
 def log(self, t, doPlaystring=None):
     # displayTest seems not to work:
     natlink.displayText(t, 0)
     if doPlaystring:
         natlink.playString(t + '\n')
     # do the global log function:
     log(t)
Esempio n. 4
0
    def testPreTests(self):
        # make sure that NatSpeak is loaded into memory
        testForException = self.doTestForException
        # these function should all fail before natConnect is called
        testForException(natlink.NatError, "natlink.playString('')")
        testForException(natlink.NatError, "natlink.getCurrentModule()")
        testForException(natlink.NatError, "natlink.getCurrentUser()")
        testForException(natlink.NatError, "natlink.getMicState()")
        testForException(natlink.NatError, "natlink.setMicState('off')")
        testForException(natlink.NatError, "natlink.execScript('')")
        testForException(natlink.NatError, "natlink.recognitionMimic('')")
        testForException(natlink.NatError, "natlink.playEvents([])")
        testForException(natlink.NatError, "natlink.inputFromFile('test.wav')")
        testForException(natlink.NatError, "natlink.setTimerCallback(None)")
        testForException(natlink.NatError, "natlink.getTrainingMode()")
        testForException(natlink.NatError,
                         "natlink.startTraining('calibrate')")
        testForException(natlink.NatError, "natlink.finishTraining()")
        testForException(natlink.NatError, "natlink.getAllUsers()")
        testForException(natlink.NatError, "natlink.openUser('testUser')")
        testForException(natlink.NatError, "natlink.saveUser()")
        testForException(natlink.NatError, "natlink.getUserTraining()")
        testForException(natlink.NatError, "natlink.waitForSpeech(0)")
        testForException(natlink.NatError, "natlink.GramObj().load('')")
        testForException(natlink.NatError, "natlink.DictObj()")

        # these functions should all work before natConnect is called
        natlink.displayText('', 0)
        natlink.getClipboard()
        natlink.getCallbackDepth()
        natlink.getCursorPos()
        natlink.getScreenSize()
        natlink.setBeginCallback(None)
        natlink.setChangeCallback(None)
        natlink.isNatSpeakRunning()
Esempio n. 5
0
    def testPreTests(self):
        # make sure that NatSpeak is loaded into memory
        testForException = self.doTestForException
        # these function should all fail before natConnect is called
        testForException( natlink.NatError, "natlink.playString('')" )
        testForException( natlink.NatError, "natlink.getCurrentModule()" )
        testForException( natlink.NatError, "natlink.getCurrentUser()" )
        testForException( natlink.NatError, "natlink.getMicState()" )
        testForException( natlink.NatError, "natlink.setMicState('off')" )
        testForException( natlink.NatError, "natlink.execScript('')" )
        testForException( natlink.NatError, "natlink.recognitionMimic('')" )
        testForException( natlink.NatError, "natlink.playEvents([])" )
        testForException( natlink.NatError, "natlink.inputFromFile('test.wav')" )
        testForException( natlink.NatError, "natlink.setTimerCallback(None)" )
        testForException( natlink.NatError, "natlink.getTrainingMode()" )
        testForException( natlink.NatError, "natlink.startTraining('calibrate')" )
        testForException( natlink.NatError, "natlink.finishTraining()" )
        testForException( natlink.NatError, "natlink.getAllUsers()" )
        testForException( natlink.NatError, "natlink.openUser('testUser')" )
        testForException( natlink.NatError, "natlink.saveUser()" )
        testForException( natlink.NatError, "natlink.getUserTraining()" )
        testForException( natlink.NatError, "natlink.waitForSpeech(0)" )
        testForException( natlink.NatError, "natlink.GramObj().load('')" )
        testForException( natlink.NatError, "natlink.DictObj()" )

        # these functions should all work before natConnect is called
        natlink.displayText('',0)
        natlink.getClipboard()
        natlink.getCallbackDepth()
        natlink.getCursorPos()
        natlink.getScreenSize()
        natlink.setBeginCallback(None)
        natlink.setChangeCallback(None)
        natlink.isNatSpeakRunning()
Esempio n. 6
0
 def write(self, text):
     # if text.find('\x00') >= 0:
     #     text = text.replace('\x00', '')
     #     text = "===Warning, text contains null bytes===\n" + text
     # if type(text) == str:
     #     text = text.encode('cp1252')
     natlink.displayText(text, 1)
Esempio n. 7
0
 def gotResults_start(self, words, fullResults):
     #pylint:disable=R0201
     natlink.displayText(
         '\nHeard macro "sample directory (info|information)"\n\n', 0)
     language = status.get_language()
     print(f'Language is: {language}')
     print(
         f'NatlinkDirectory from status (natlinkstatus): {status.getNatlinkDirectory()}'
     )
     print(
         f'NatlinkUserDirectory from natlinkcore: {natlinkcore.getNatlinkUserDirectory()}'
     )
Esempio n. 8
0
 def write(self, text):
     natlink.displayText(text, self._error)
 def log(self, t):
     if self.isConnected:
         natlink.displayText(t, 0)
     else:
         print(t)
     print(t, file=open(logFileName, "a"))
Esempio n. 10
0
 def write(self, text):
     natlink.displayText(text, self._error)
Esempio n. 11
0
 def write(self, text):
     natlink.displayText(text, 0)
Esempio n. 12
0
 def write(self, text: AnyStr) -> int:
     if not isinstance(text, str):
         raise ValueError(f'Can only write str, not {type(text)}')
     natlink.displayText(text, True)
     return len(text)
Esempio n. 13
0
 def gotResults_start(self, words, fullResults):
     natlink.displayText('Heard macro "sample one"{enter}', 0)
Esempio n. 14
0
 def write(self,text):
     natlink.displayText(text, 1)