Good Morning,
I have a problem with a project i made. Its basically Chat GPT but u give voice as an input and it will also give voice as output. But i asked the gpt whats todays date and it gives random dates in 2020. Every time i run it it says dates which is in the year 2020. This is my code :
import openai
import pyttsx3
import speech_recognition as sr
from api_key import API_KEY
openai.api_key = API_KEY
engine = pyttsx3.init()
r = sr.Recognizer()
mic = sr.Microphone(device_index=1)
voice = engine.getProperty('voices')
engine.setProperty('voice', voice[1].id)
conversation = ""
user_name = "ANOYMOUS"
bot_name = "GPT-3"
while True:
with mic as source:
print("\nlistening...")
r.adjust_for_ambient_noise(source, duration=0.2)
audio = r.listen(source)
print("no longer listening.\n")
try:
user_input = r.recognize_google(audio)
except:
continue
prompt = user_name + ": " + user_input + "\n" + bot_name+ ": "
conversation += prompt
response = openai.Completion.create(engine='text-davinci-003', prompt=conversation, max_tokens=100)
response_str = response["choices"][0]["text"].replace("\n", "")
response_str = response_str.split(user_name + ": ", 1)[0].split(bot_name + ": ", 1)[0]
conversation += response_str + "\n"
print(response_str)
engine.say(response_str)
engine.runAndWait()
I have attached the out put in this message.