Audio Translation
Translate spoken audio from any language directly into English text using AI providers. aiTranslate() is distinct from text translation — it converts speech to English in a single transcription step.
aiTranslate() converts spoken audio in any language directly into English text. This is distinct from text-to-text language translation — think of it as "transcribe and translate in one step."
🚨 Important:
aiTranslate()does NOT translate between arbitrary languages. It always produces English output regardless of the source language. If you need to transcribe audio and preserve the original language, useaiTranscribe()instead.
How It Works
aiTranscribe() vs aiTranslate()
aiTranscribe()
aiTranslate()
Output language
Same as input audio
Always English
Source audio
Any language
Any language
Use case
Preserve original speech
Understand any-language audio in English
Providers
OpenAI, Groq
OpenAI, Groq
Provider Support
OpenAI
✅ Yes
Groq
✅ Yes
Mistral
❌ No
Gemini
❌ No
ElevenLabs
❌ No
Grok / xAI
❌ No
🔧 The aiTranslate() Function
Syntax
The signature is identical to aiTranscribe(). All parameters, options, and returns are the same.
Parameters
audio
string or binary
✅ Yes
File path, URL, or raw binary audio data
params
struct
No
Provider API parameters (model, temperature, etc.)
options
struct
No
Module-level options (provider, returnFormat, responseFormat, etc.)
Options
provider
string
(config)
openai or groq
apiKey
string
(env var)
Provider API key
returnFormat
string
"text"
"text" — plain string; "response" — AiTranscriptionResponse
responseFormat
string
"json"
json, text, verbose_json, srt, vtt
timeout
numeric
30
HTTP timeout in seconds
logRequest
boolean
false
Log requests to the module log file
logRequestToConsole
boolean
false
Print request payload to console
logResponse
boolean
false
Log responses
logResponseToConsole
boolean
false
Print raw provider response to console
The
languageoption does not apply toaiTranslate()— the output language is always English.
💡 Examples
Basic — translate any-language audio to English
Transcribe vs translate — side by side
Full response object
Fast translation with Groq
Translate from a URL
Translate binary audio data
🧱 Fluent Builder API (v3.2.0+)
Calling aiTranslate() with no arguments returns an AiTranscriptionRequest builder object for method chaining. The builder shares the same methods as aiTranscribe() — the only difference is the .translate() terminator.
Basic Builder Usage
Fluent Examples
💡 Backward Compatible: The traditional
aiTranslate( audio, params, options )syntax continues to work unchanged. The fluent builder is an additional option — no migration required.
📡 Events
beforeAITranslation
transcriptionRequest, service
afterAITranslation
transcriptionRequest, service, result
📖 Related Pages
Last updated