我使用OpenAI与AI对话,但为了与之对话,我必须输入提示部分,其中写着人工,打印响应,然后它会对我说话,但只会说一次。有没有一种方法可以将文本转换成文本,将文本转化为文本?
import os
import openai
openai.api_key = 'not saying my api key'
start_sequence = "\nAI:"
restart_sequence = "\nHuman: "
response = openai.Completion.create(
model="text-davinci-002",
prompt="The following is a conversation with an AI assistant. The assistant is helpful, creative, clever, and very friendly.\n\nHuman: Hello, who are you?\nAI: I am an AI created by OpenAI. How can I help you today?\nHuman: ",
temperature=0.9,
max_tokens=150,
top_p=1,
frequency_penalty=0,
presence_penalty=0.6,
stop=[" Human:", " AI:"]
)
print(response)
发布于 2022-08-29 19:16:38
如果您使用的是笔记本:
import os
from gtts import gTTS
from IPython.display import Audio, display
def talk(text):
# convert text to speech, save to audio file
gTTS(text).save('temp.wav')
# load audio file, play sound
display(Audio('temp.wav', autoplay=True))
# remove temporary file
os.remove('temp.wav')
https://stackoverflow.com/questions/73533043
复制相似问题