File size: 621 Bytes
e6c4009
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import gradio as gr
import openai

# Set API Key
openai.api_key = "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"

# Define a function that will use OpenAI's API to transcribe an audio file
def transcribe_audio(inp):
    with open(inp.name, 'rb') as file:
        transcript = openai.Audio.transcribe("whisper-1", file)
    return transcript["text"]

# Define the Gradio interface
iface = gr.Interface(fn=transcribe_audio, 
                     inputs=gr.inputs.Audio(source="microphone", type="filepath", label="Record audio"), 
                     outputs="text")

# Launch the interface
iface.launch(share=True)