#๐ python and chatgpt
13 messages ยท Page 1 of 1 (latest)
@hidden obsidian
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
@hidden obsidian you just sent your api key
I recommend you remove it from the code you sent and change it
@hidden obsidian I deleted your message, since it contained your API key. Please change your API key as soon as possible, or you will have to pay for whatever people do with it!!!
oh thanks
alo
um
`import os
import time
import pyaudio
import speech_recognition as sr
import playsound
from gtts import gTTS
import openai
api_key = "insert api"
lang = 'en'
openai.api_key = api_key
guy = ""
while True:
def get_adio():
r = sr.Recognizer()
with sr.Microphone(device_index=1) as source:
audio = r.listen(source)
said = ""
try:
said = r.recognize_google(audio)
print(said)
global guy
guy = said
if "Test" in said:
words = said.split()
new_string = ' '.join(words[1:])
print(new_string)
completion = openai.ChatCompletion.create(model="gpt-3.5-turbo",
messages=[{"role": "user", "content": said}])
text = completion.choices[0].message.content
speech = gTTS(text=text, lang=lang, slow=False, tld="com.au")
speech.save("welcome1.mp3")
playsound.playsound("welcome1.mp3")
except Exception:
print("Exception")
return said
if "stop" in guy:
break
get_adio() `
can I get help with this?
I need to change it to ChatGPT 4
!close
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.