hey_rehan / stt.py
muhammadnasar's picture
Upload 6 files
6cc9795 verified
raw
history blame contribute delete
413 Bytes
from openai import OpenAI
from dotenv import load_dotenv
import os
load_dotenv()
client = OpenAI(api_key=os.getenv("openai_api_key"))
def transcribe_audio(audio_file):
with open(audio_file, "rb") as audio_file:
transcription = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file,
response_format="text"
)
return transcription