GlycoAgent / audio_stt.py
JulianTekles's picture
Upload 10 files
4cb4283 verified
raw
history blame contribute delete
398 Bytes
import os
from openai import OpenAI
def transcribe_audio(file_path: str, language: str = "de") -> str:
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
with open(file_path, "rb") as f:
resp = client.audio.transcriptions.create(
model="gpt-4o-mini-transcribe",
file=f,
language=language,
)
return getattr(resp, "text", str(resp))