from openai import OpenAI
from obiguard import OBIGUARD_GATEWAY_URL, createHeaders
client = OpenAI(
api_key="dummy" # Placeholder; the provider credential is stored in Obiguard
base_url=OBIGUARD_GATEWAY_URL,
default_headers=createHeaders(
api_key="ak***", # Your Obiguard access key here
)
)
audio_file= open("/path/to/file.mp3", "rb")
# Transcription
transcription = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file
)
print(transcription.text)
# Translation
translation = client.audio.translations.create(
model="whisper-1",
file=audio_file
)
print(translation.text)