This is a python script that allows you to speak to GPT-3

From a quick glance, this should work. Errors are always likely, I recommend you lower the max_tokens when you’re testing, it can get expensive otherwise.

For your own function, a mistake you have.

saytext = ttsRequesthandler(SpeechText, "3")

You shouldn’t let the API handle SpeechText, that’s the voice input you give. The output that the OpenAPI gives is:


This should be something like

var1 =  response.choices[0].text
saytext = ttsRequesthandler(var1, "3")

has to change.

Also, make sure you remove the last few lines:

            # SPEAK IT OUT
            engine = pyttsx3.init()

Otherwise you’ll have multiple voices.Perhaps remove the entire pyttsx library, at that point it’s only bloat. Good luck.