Translation

Translation enables converting content between languages using two approaches: runtime translation during transcription and post-processing translation on text.

ShunyaLabs provides two translation methods:

  • Runtime Translation — Audio in any language → Any supported language
  • Post-Processing Translation — Text → Any supported language

For supported languages, see the Languages section.

Method 1: Runtime Translation

Automatically converts speech in any language to English text during transcription using the model’s built-in translation capability.

How to Enable

"task": "translate",
"target_language":"en" #Replace with preferred language code

Request

Don’t forget to replace YOUR_API_KEY with your own secret key.
import requests

url = "https://tb2.shunyalabs.ai/v1/transcriptions"
headers = {"X-API-Key": "your-api-key"}

with open("hindi_audio.wav", "rb") as f:
    files = {"file": f}
    data = {
        "task": "translate",
        "target_language":"en" #Replace with preferred language code
    }

    response = requests.post(
        url,
        headers=headers,
        files=files,
        data=data
    )

print(response.json())

Example Output

{
  "success": true,
  "text": "Hello, how can I help you today?",
  "segments": [
    {
      "start": 0.0,
      "end": 4.5,
      "text": "Hello, how can I help you today?",
      "speaker": "SPEAKER_00"
    }
  ]
}

Note: Original Hindi audio —नमस्ते, आज मैं आपकी कैसे मदद कर सकता हूँ?— is automatically translated into English.

Method 2: Post-Processing Translation

Converts text from one language to another. This works for any text, including completed transcriptions.

Parameters

  • text — Input text to translate (required)
  • source_lang — Source language code (optional, default: en)
  • target_lang — Target language code (required)

Request

Don’t forget to replace YOUR_API_KEY with your own secret key.
import requests

url = "https://tb.shunyalabs.ai/v1/translate"
headers = {"X-API-Key": "your-api-key"}

data = {
    "text": "Hello, how are you?",
    "source_lang": "en",
    "target_lang": "hi"
}

response = requests.post(url, headers=headers, data=data)
print(response.json())

Example Output

{
  "original_text": "Hello, how are you?",
  "translated_text": "नमस्ते, आप कैसे हैं?",
  "source_language": "en",
  "target_language": "hi"
}

Best Practices

  • Use runtime translation for audio → English workflows
  • Use post-processing translation for non-English outputs
  • Specify source_lang for higher accuracy

Use Cases

  • International customer support
  • Multilingual content delivery
  • Global training materials
  • Accessibility and localization
  • Business intelligence on non-English data
  • Legal and compliance documentation