Skip to main content

Supported Providers

  • OpenAI
  • Azure OpenAI
  • Groq
The Translations API converts spoken audio into English text using the whisper-1 model. You can provide audio in a variety of formats, and the API will return an accurate English translation. You can customize the input and output as follows:
  • Model: whisper-1
  • Input formats: mp3, mp4, mpeg, mpga, m4a, wav, webm
  • Output: Translated English text

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?"
}
I