Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import openai
|
3 |
+
import os
|
4 |
+
|
5 |
+
openai.api_key = os.getenv("OPENAI_API_KEY")
|
6 |
+
|
7 |
+
def transcribe_audio(file):
|
8 |
+
transcript = openai.Audio.transcribe("whisper-1", file)
|
9 |
+
return transcript.text.strip()
|
10 |
+
|
11 |
+
def translate_audio(file):
|
12 |
+
transcript = openai.Audio.translate("whisper-1", file)
|
13 |
+
return transcript.text.strip()
|
14 |
+
|
15 |
+
audio_input = gr.inputs.Audio(label="Upload Audio File")
|
16 |
+
output_text = gr.outputs.Textbox(label="Transcribed Text")
|
17 |
+
interface = gr.Interface(fn=transcribe_audio, inputs=audio_input, outputs=output_text)
|
18 |
+
interface.launch()
|
19 |
+
|