Esempio n. 1
0
    def interpret(self, what):
        global sentence

        parser.feed(what)

        if len(sentence) > 0:
            segregator = Segregator(' '.join(sentence))
            segregator.segregate_and_react()
            sentence = []
Esempio n. 2
0
class SegregatorTestCase(unittest.TestCase):
    def tearDown(self):
        del self.segregator

    def test_should_return_true_if_sentence_is_a_greeting(self):
        self.segregator = Segregator("good morning")
        self.assertTrue(self.segregator.check_if_greeting())

    def test_should_return_false_if_sentence_is_not_a_greeting(self):
        self.segregator = Segregator("i am bored")
        self.assertFalse(self.segregator.check_if_greeting())
Esempio n. 3
0
class SegregatorTestCase(unittest.TestCase):
    def tearDown(self):
        del self.segregator

    def test_should_return_true_if_sentence_is_a_greeting(self):
        self.segregator = Segregator("good morning")
        self.assertTrue(self.segregator.check_if_greeting())

    def test_should_return_false_if_sentence_is_not_a_greeting(self):
        self.segregator = Segregator("i am bored")
        self.assertFalse(self.segregator.check_if_greeting())
Esempio n. 4
0
 def test_should_return_true_if_sentence_is_a_greeting(self):
     self.segregator = Segregator("good morning")
     self.assertTrue(self.segregator.check_if_greeting())
Esempio n. 5
0
 def test_should_return_false_if_sentence_is_not_a_greeting(self):
     self.segregator = Segregator("i am bored")
     self.assertFalse(self.segregator.check_if_greeting())
Esempio n. 6
0
 def onMessage(self, payload, is_binary):
     if not self.is_speaking:
         self.is_speaking = True
         segregator = Segregator(payload.decode("utf8"))
         segregator.segregate_and_react()
         self.is_speaking = False
Esempio n. 7
0
    "--input", help="specify the input source mic/stdin, default is stdin")
parser.add_argument("--host",
                    help="specify julius' host, default is localhost")
parser.add_argument("--port",
                    help="specify julius' port, default is 10500",
                    type=int)
args = parser.parse_args()

if not os.path.exists(".CHAT_SERVER_PID"):
    process = subprocess.Popen([sys.executable, "chat_ui/chat_ui_server.py"])

    with open(".CHAT_SERVER_PID", "w") as pid:
        pid.write(str(process.pid))
else:
    with open(".CHAT_SERVER_PID") as pid:
        subprocess.call(['kill', pid.readlines()[0].strip()])

    os.remove(".CHAT_SERVER_PID")

src = "mic" if (args.input and args.input == "mic") else "stdin"

say("Hello. I'm at your service.")
while True:
    if src == "stdin":
        sentence = raw_input("Type something: ")
    else:
        sentence = user_input("Say something: ")

    segregator = Segregator(sentence)
    segregator.segregate_and_react()
Esempio n. 8
0
 def onMessage(self, payload, is_binary):
     if not self.is_speaking:
         self.is_speaking = True
         segregator = Segregator(payload.decode('utf8'))
         segregator.segregate_and_react()
         self.is_speaking = False
Esempio n. 9
0
 def test_should_return_true_if_sentence_is_a_greeting(self):
     self.segregator = Segregator("good morning")
     self.assertTrue(self.segregator.check_if_greeting())
Esempio n. 10
0
 def test_should_return_false_if_sentence_is_not_a_greeting(self):
     self.segregator = Segregator("i am bored")
     self.assertFalse(self.segregator.check_if_greeting())