-1

Hi i'm new to programming and i am facing this issue where the labels are not updated only until the synthesize function is completed. Should i look into async programming to solve this issue?

self.responseText.config(text = res) and self.changePic(responseImagePath) are to change the label properties. Thanks.

    def chatBot(self):

    audio_source.is_recording = True

    # STT
    stream.start_stream()

    recognize_using_websocket()

    # ASSISTANT
    message = assistant.message(
        assistant_id = CONFIG["assistant"]["assistant_id"],
        session_id = session,
        input = { 'text': recordedInput }
    ).get_result()

    print(message)
    res = message["output"]["generic"][0]["text"]
    self.responseText.config(text = res)
    print("Response: " + res)


    if imagePresence(message) == True:
        responseImagePath =  message["output"]["generic"][1]["source"]
        print("Response Image src: " + responseImagePath)
        self.changePic(responseImagePath)



    # TTS
    test_callback = MySynthesizeCallback()

    tts.synthesize_using_websocket(
        res,
        test_callback,
        accept = "audio/wav",
        voice = "en-US_AllisonVoice"
    )
  • Does this answer your question? [use threads to preventing main event loop from “freezing”](https://stackoverflow.com/a/16747734/7414759) – stovfl Jun 11 '20 at 16:59

1 Answers1

0

I'm pretty new to programming as you and I build discord bots when async is required! Looking at your situation, I see function blocks all your code until it completes. If you learn async python you can, as I understood it "split your program to do different task".

So, I think yes. But I can be incorrect.

Sorry, if didn't help

provit_026
  • 11
  • 3