File size: 812 Bytes
fd39862
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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()