Using Transcription and Translation
Obiguard provides both Transcription
and Translation
options for speech-to-text (STT) models,
following the OpenAI API format. You can submit audio files in formats such as flac
, mp3
, mp4
, mpeg
, mpga
, m4a
, ogg
, wav
, or webm
as part of your API request.
Example:
Python SDK OpenAI Python cURL from pathlib import Path
from obiguard import Obiguard
# Initialize the Obiguard client
client = Obiguard(
virtual_key="vk-obg***" # Your Obiguard virtual 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)
from pathlib import Path
from obiguard import Obiguard
# Initialize the Obiguard client
client = Obiguard(
virtual_key="vk-obg***" # Your Obiguard virtual 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)
from openai import OpenAI
from obiguard import OBIGUARD_GATEWAY_URL, createHeaders
client = OpenAI(
api_key="dummy" #We are using Virtual Key from Obiguard
base_url=OBIGUARD_GATEWAY_URL,
default_headers=createHeaders(
api_key="vk-obg***", # Your Obiguard virtual 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)
For Transcriptions:
curl "https://gateway.obiguard.ai/v1/audio/transcriptions" \
-H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
-H "x-obiguard-provider: openai" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H 'Content-Type: multipart/form-data' \
--form file=@/path/to/file/audio.mp3 \
--form model=whisper-1
For Translations:
curl "https://gateway.obiguard.ai/v1/audio/translations" \
-H "x-obiguard-api-key: $OBIGUARD_API_KEY" \
-H "x-obiguard-provider: openai" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H 'Content-Type: multipart/form-data' \
--form file=@/path/to/file/audio.mp3 \
--form model=whisper-1
After completion, your request will appear in the logs UI, displaying the transcribed or translated text, as well as the associated cost and latency.
Supported Providers and Models
Currently, the following providers are supported for speech-to-text.
More providers will be added soon.
Provider Model Functions OpenAI whisper-1 Transcription, Translation