Spaces:
Sleeping
Sleeping
import base64 | |
import requests | |
import tempfile | |
import streamlit as st | |
from openai import OpenAI | |
# Whisper transcription function | |
def transcribe_audio(file_path, api_key): | |
with open(file_path, "rb") as f: | |
response = requests.post( | |
"https://api.openai.com/v1/audio/transcriptions", | |
headers={"Authorization": f"Bearer {api_key}"}, | |
files={"file": f}, | |
data={"model": "whisper-1"} | |
) | |
return response.json().get("text", None) | |