Skip to main content

Translation

Translation is the process of converting text or speech from one language into another. It ensures inclusivity, accessibility, and wider reach for content that originates in one specific language.

For example, for a video that is in Arabic, adding English subtitles could enable it to get much wider reach among non-Arabic speaking audiences. It is also useful for educational content, as it enables people to access content in the language of their choice.

File Transcription Job with Sentiment Analysis

Copy and paste the below curl request on your terminal to start a transcription using the API. Fill the variables with the appropriate values, as mentioned in the overview.

curl --location 'https://voice.neuralspace.ai/api/v1/jobs' \
--header 'Authorization: {{API_KEY}}' \
--form 'files=@"{{LOCAL_AUDIO_FILE_PATH}}"' \
--form 'config="{\"file_transcription\":{\"language_id\":\"{{LANG}}\", \"mode\":\"{{MODE}}\"},
\"translation\": {\"target_languages\": [\"hi\", \"ar\"]}}\"'

In the above request, translation is an extra configuration that is being passed. It needs a list of target language codes. It also returns a response similar to the regular file transcription API as seen in overview.

{
"success": true,
"message": "Job created successfully",
"data": {
"jobId": "281f8662-cdc3-4c76-82d0-e7d14af52c46"
}
}
Target language codes

As shown above, you can pass multiple target language codes as a list to the API. The supported translation target languages and their corresponding codes can be found under language Support.

Number of target language codes

Only a maximum of 5 target language codes can be passed in a single request.

Fetch Transcription and Sentiment Analysis Results

When you pass the jobId (received in response to the transcription API) to the API below, it fetches the status and results of the job.

curl --location 'https://voice.neuralspace.ai/api/v1/jobs/{{jobId}}' \
--header 'Authorization: {{API_KEY}}'

The response of the request above appears as follows:

{
...
"data": {
...
"result": {
...
"translation": {
"hi": {
"text": "हम इस पर घंटों से हैं। क्या आपको इनमें से किसी पुस्तक में कुछ उपयोगी मिला? एक भी चीज़ नहीं, लुईस। मुझे यकीन है कि इस लाइब्रेरी में जरूर कुछ होगा। ऐसा नहीं है कि खोजने के लिए कुछ भी नहीं बचा है। खैर, मुझे यह कहना होगा कि मैं खोजते-खोजते थक गया हूं। मैं थोड़ा ब्रेक लूंगा।",
"segments": [
{
"startTime": 6.6909375,
"endTime": 10.302187500000002,
"text": "हम इस पर घंटों से हैं। क्या आपको इनमें से किसी पुस्तक में कुछ उपयोगी मिला?",
"speaker": "SPEAKER_02"
},
{
"startTime": 10.690312500000001,
"endTime": 14.588437500000001,
"text": "एक भी चीज़ नहीं, लुईस। मुझे यकीन है कि इस लाइब्रेरी में जरूर कुछ होगा।",
"speaker": "SPEAKER_01"
},
{
"startTime": 14.740312500000002,
"endTime": 16.545937499999997,
"text": "ऐसा नहीं है कि खोजने के लिए कुछ भी नहीं बचा है।",
"speaker": "SPEAKER_01"
},
{
"startTime": 17.2378125,
"endTime": 21.5071875,
"text": "खैर, मुझे यह कहना होगा कि मैं खोजते-खोजते थक गया हूं। मैं थोड़ा ब्रेक लूंगा।",
"speaker": "SPEAKER_02"
}
]
},
"ar": {
"text": "لقد كنا في هذا لساعات الآن. هل وجدت شيئا مفيدا في أي من تلك الكتب؟ لا شيء واحد، لويس. أنا متأكد من أنه يجب أن يكون هناك شيء ما في هذه المكتبة.",
"segments": [
{
"startTime": 6.6909375,
"endTime": 10.302187500000002,
"text": "لقد كنا في هذا لساعات الآن. هل وجدت شيئا مفيدا في أي من تلك الكتب؟",
"speaker": "SPEAKER_02"
},
{
"startTime": 10.690312500000001,
"endTime": 14.588437500000001,
"text": "لا شيء واحد، لويس. أنا متأكد من أنه يجب أن يكون هناك شيء ما في هذه المكتبة.",
"speaker": "SPEAKER_01"
},
{
"startTime": 14.740312500000002,
"endTime": 16.545937499999997,
"text": "ليس الأمر كما لو أنه لم يتبق شيء يمكن اكتشافه.",
"speaker": "SPEAKER_01"
},
{
"startTime": 17.2378125,
"endTime": 21.5071875,
"text": "حسنًا، يجب أن أقول إنني تعبت من البحث. سآخذ استراحة قصيرة.",
"speaker": "SPEAKER_02"
}
]
}
}
}
}
}

In the response above, an overall translation is returned. Translations are present in a dictionary called translation. The keys in it are the target language code(s) that were passed while the job was created.Segment-wise translations, if speaker diarization is enabled, would be returned as shown above as well.

info
  • If you have selected the speaker diarization feature while creating the job, you will also receive a segment-wise list of translations in addition to the full text translation. This list of segments is unavailable when speaker diarization is not enabled, and only the overall translation of the whole transcript is returned.
  • If you have selected the summarization feature while creating the job, in addition to translation of the transcripts, you also get translations of the summary.

Troubleshooting and FAQ

Ealiq (en: stuck)? Check out our FAQ page. If you still need help, feel free to reach out to us directly at support@neuralspace.ai or join our Slack community.