Spaces:
Runtime error
Runtime error
Download app.py from Phoenix7/CR: direct link, hf CLI and curl.
- Browser
- Download file 617 Bytes
-
https://huggingface.co/spaces/Phoenix7/CR/resolve/main/app.py
- Command line
-
hf download hf://spaces/Phoenix7/CR/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Phoenix7/CR/resolve/main/app.py
617 Bytes
| 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) |