Was implementing chatgpt on raspberry pi-4, using google voice recognizer. When I run the code, it is able to take input from microphone and display it but showing the error after that. Error it is showing:
Exception in Tkinter callback
Traceback (most recent call last):
File “/usr/lib/python3.11/tkinter/init_.py”, line 1948, in _call
return self.func(*args)
^^^^^^^^^^^^^^^^
File “/home/youngovator/rpichatgpt/search.py”, line 14, in info
chat = openai.ChatCompletion.create(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/youngovator/rpichatgpt/venv/lib/python3.11/site-packages/openai/api_resources/chat_completion.py”, line 25, in create
return super().create(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/youngovator/rpichatgpt/venv/lib/python3.11/site-packages/openai/api_resources/abstract/engine_api_resource.py”, line 153, in create
response, _, api_key = requestor.request(
^^^^^^^^^^^^^^^^^^
File “/home/youngovator/rpichatgpt/venv/lib/python3.11/site-packages/openai/api_requestor.py”, line 298, in request
resp, got_stream = self._interpret_response(result, stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/youngovator/rpichatgpt/venv/lib/python3.11/site-packages/openai/api_requestor.py”, line 700, in _interpret_response
self._interpret_response_line(
File “/home/youngovator/rpichatgpt/venv/lib/python3.11/site-packages/openai/api_requestor.py”, line 765, in _interpret_response_line
raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.
The code:
`
import speech_recognition as sr
from gtts import gTTS
import os
import time
from tkinter import *
def audio():
# Record Audio
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
r.adjust_for_ambient_noise(source)
audio = r.listen(source)
data = r.recognize_google(audio)
print(data)
return data
def speak(audiostring):
tts=gTTS(text=audiostring,lang="en")
tts.save("audio.mp3")
os.system("mpg321 audio.mp3")
import os
from ai import audio,speak
import openai
openai.api_key = 'KEY'
messages = [ {"role": "system", "content": "You are an intelligent assistant." } ]
def info():
message=audio().replace(" ","")
messages.append(
{"role": "user", "content": message},
)
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)
reply = chat.choices[0].message
print("Assistant: ", reply.content)
speak(reply.content)
messages.append(reply)
from tkinter import *
from search import info
win = Tk()
win.geometry('320x50');win.title('Freedomtech Player')
button = Button(win, text="Speak", command = info )
button.pack()
win.mainloop()
`
I tried logging in on openai platform with different gmail accounts as it was showing ‘exceeded your current quota’, but for the very first run only it was showing the same error.
Nithyasree Kalashkam is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.