예제 #1
0
파일: __main__.py 프로젝트: mjdarby/Joshu
from threading import RLock
from .client import runClientThread, sendCommand
from app.shared.response import Response
from app.speechsynth import voice

if __name__ == "__main__":
    host = sys.argv[1]

    def callback(data):
        response = Response.decodeJson(data)
        voice.speak(response.text)

    # Setup
    lock = RLock()
    clientThread, server = runClientThread(lock, callback)

    # Main loop
    while True:
        data = input(">")
        if data == "quit":
            with lock:
                server.shutdown()
                break

        received = sendCommand(host, data, lock)
        response = Response.decodeJson(received)
        voice.speak(response.text)

    # Cleanup
    clientThread.join()
예제 #2
0
파일: __main__.py 프로젝트: mjdarby/Joshu
 def callback(data):
     response = Response.decodeJson(data)
     voice.speak(response.text)
예제 #3
0
파일: __main__.py 프로젝트: mjdarby/Joshu
def processResponse(json):
    try:
        response = Response.decodeJson(json)
        voiceResponse(response.text, response.mood, character)
    except JSONDecodeError:
        voiceResponse("Oops, something went wrong.", "neutral", character)