Spaces:
Runtime error
Runtime error
File size: 617 Bytes
f7310e6 f92c539 f7310e6 f92c539 f7310e6 f92c539 f7310e6 f92c539 f7310e6 eb93ade f7310e6 f92c539 |
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 |
import gradio as gr
import openai
from pathlib import Path
import os
# openai.api_key = os.environ.get('OPEN_API_KEY')
openai.api_key = "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"
def transcribe(audio):
print(audio)
myfile=Path(audio)
myfile=myfile.rename(myfile.with_suffix('.wav'))
audio_file= open(myfile, "rb")
transcript = openai.Audio.transcribe("whisper-1", audio_file)
print(transcript)
return transcript["text"]
demo = gr.Interface(fn=transcribe, inputs=gr.Audio(source="microphone", type="filepath"), outputs="text")
demo.launch()
#demo.launch(share=True) |