Пример #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)
Пример #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)
Пример #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)
Пример #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()
Пример #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()
Пример #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)
Пример #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()}'
     )
Пример #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"))
Пример #10
0
 def write(self, text):
     natlink.displayText(text, self._error)
Пример #11
0
 def write(self, text):
     natlink.displayText(text, 0)
Пример #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)
Пример #13
0
 def gotResults_start(self, words, fullResults):
     natlink.displayText('Heard macro "sample one"{enter}', 0)
Пример #14
0
 def write(self,text):
     natlink.displayText(text, 1)