Supported Providers

  • OpenAI
  • Azure OpenAI
  • Groq
The translations API takes as input the audio file you want to translate and translates it from any supported language to English text. The API is powered by Whisper models and supports various input audio formats. The Whisper model supports input formats (mp3, mp4, mpeg, mpga, m4a, wav, webm). On output, the API returns the translated text in English.

Code Snippet

from openai import OpenAI

BASE_URL = "https://{controlPlaneUrl}/api/llm"
API_KEY = "your-truefoundry-api-key"

# Configure OpenAI client with TrueFoundry settings
client = OpenAI(
    api_key=API_KEY,
    base_url=BASE_URL,
)

audio_file= open("/path/to/file/audio.mp3", "rb")

translation = client.audio.translations.create(
    model="openai-main/whisper-1",
    file=audio_file
)

print(translation.text)
By default, the response type will be json with the raw text included.
{
  "text": "Hello, how are you?"
}