pitchscreen / app.py
kotrotsos's picture
first
fd39862
raw
history blame contribute delete
812 Bytes
import openai
import gradio as gr
import os
openai.api_key = os.environ.get("openai_key")
def transcribe(audio):
audio_file = open(audio, "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
text = transcript.text
preprompt = "You are a very helpful sales coach. Please review the following cold call introduction for me. Tell me what you think of this cold call: "
res=openai.Completion.create(
model="text-davinci-003",
prompt= preprompt + text,
max_tokens=256,
temperature=0
)
response = str(res["choices"][0]["text"].strip())
full = f"{text}\n\nThank you, my review below:\n{response}"
return full
ui = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
ui.launch()