Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,19 +1,19 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
# openai.api_key = os.environ.get('OPEN_API_KEY')
|
| 7 |
-
openai.api_key = "sk-
|
| 8 |
|
| 9 |
|
| 10 |
def transcribe(audio):
|
| 11 |
print(audio)
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
audio_file= open(
|
| 17 |
|
| 18 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
| 19 |
print(transcript)
|
|
@@ -23,4 +23,4 @@ def transcribe(audio):
|
|
| 23 |
demo = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
|
| 24 |
|
| 25 |
demo.launch()
|
| 26 |
-
#demo.launch(share=True)
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import openai
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
# openai.api_key = os.environ.get('OPEN_API_KEY')
|
| 7 |
+
openai.api_key = "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"
|
| 8 |
|
| 9 |
|
| 10 |
def transcribe(audio):
|
| 11 |
print(audio)
|
| 12 |
|
| 13 |
+
myfile=Path(audio)
|
| 14 |
+
myfile=myfile.rename(myfile.with_suffix('.wav'))
|
| 15 |
|
| 16 |
+
audio_file= open(myfile, "rb")
|
| 17 |
|
| 18 |
transcript = openai.Audio.transcribe("whisper-1", audio_file)
|
| 19 |
print(transcript)
|
|
|
|
| 23 |
demo = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
|
| 24 |
|
| 25 |
demo.launch()
|
| 26 |
+
#demo.launch(share=True)
|