Пример #1
0
    def interpret(self, what):
        global sentence

        parser.feed(what)

        if len(sentence) > 0:
            segregator = Segregator(' '.join(sentence))
            segregator.segregate_and_react()
            sentence = []
Пример #2
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()
Пример #3
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
Пример #4
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