提问人:毓言桂 提问时间:11/15/2023 最后编辑:toyota Supra毓言桂 更新时间:11/15/2023 访问量:42
在 Anaconda Powershell 提示符 (anaconda3) 中输入 python project3.py 后
after i enter python project3.py in Anaconda Powershell Prompt (anaconda3)
问:
import gradio as gr
import openai, subprocess
openai.api_key = "sk-PFIsH04TaCgUrbnjnnlkT3BlbkFJ9FmjONClKC"
messages = [{"role": "system", "content": 'You are a master of dressing, and no clothing problem can trouble you.'}]
def transcribe(audio):
global messages
audio_file = open(audio, "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
messages.append({"role": "user", "content": transcript["text"]})
response = openai.ChatCompletion.create(model="ft:gpt-3.5-turbo", messages=messages)
system_message = response["choices"][0]["message"]
messages.append(system_message)
subprocess.call(["wsay", system_message['content']])
chat_transcript = ""
for message in messages:
if message['role'] != 'system':
chat_transcript += message['role'] + ": " + message['content'] + "\n\n"
return chat_transcript
ui = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text").launch()
ui.launch()
错误:
(base) PS C:\Users\user\Downloads\yolov7-main\yolov7-main> python project3.py
Traceback (most recent call last):
File "C:\Users\user\Downloads\yolov7-main\yolov7-main\project3.py", line 30, in <module>
ui = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone"), outputs="text").launch()
File "C:\Users\user\anaconda3\lib\site-packages\gradio\component_meta.py", line 146, in wrapper
return fn(self, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'source'
有人可以帮我吗?
答:
0赞
link89
11/15/2023
#1
这是一个错别字,应该代替.错误消息已经告诉您 don't have 关键字参数 。以下是音频组件的文档: https://www.gradio.app/docs/audiosources
source
gr.Audio
source
评论