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/v2/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/v2/jobs/{{jobId}}' \
--header 'Authorization: {{API_KEY}}'

The response of the request above appears as follows:

{
...
"data": {
...
"result": {
...
"translation": {
"hi": {
"channels": {
"0": "हम इस पर घंटों से हैं\nअब। क्या आपको कुछ उपयोगी मिला?\nउन किताबों में से किसी में? एक भी चीज़ नहीं,\nलुईस. मुझे यकीन है कि होना ही चाहिए\nइस पुस्तकालय में कुछ..."
},
"segments": [
{
"startTime": 6.741562500000001,
"endTime": 8.45,
"text": "हम इस पर घंटों से हैं\nअब।",
"speaker": "Speaker 1",
"channel": 0
},
{
"startTime": 8.45,
"endTime": 10.200937500000002,
"text": "क्या आपको कुछ उपयोगी मिला?\nउन किताबों में से किसी में?",
"speaker": "Speaker 1",
"channel": 0
},
...

],
"summary": "सारांश: वक्ता पुस्तकालय में कुछ उपयोगी खोज रहे हैं लेकिन उन्हें कुछ नहीं मिला। वे छुट्टी लेने और भोजन लेने का निर्णय लेते हैं। ..."
},
"ar": {
"channels": {
"0": "لقد كنا في هذا لساعات\nالآن. هل وجدت أي شيء مفيد\nفي أي من تلك الكتب؟ ليس شيئًا واحدًا،\nلويس. أنا متأكد من أنه يجب أن يكون هناك\nشيء في هذه المكتبة. ليس الأمر كما لو أنه لا يوجد شيء..."
},
"segments": [
{
"startTime": 6.741562500000001,
"endTime": 8.45,
"text": "لقد كنا في هذا لساعات\nالآن.",
"speaker": "Speaker 1",
"channel": 0
},
{
"startTime": 8.45,
"endTime": 10.200937500000002,
"text": "هل وجدت أي شيء مفيد\nفي أي من تلك الكتب؟",
"speaker": "Speaker 1",
"channel": 0
},
...
],
"summary": "ملخص: لقد بحث المتحدثون في المكتبة عن شيء مفيد ولكنهم لم يعثروا على أي شيء. ..."
}
},
}
}
}

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. And if a multichannel audio is passed with speaker diarization enabled with mode channels, full translated transcripts for each channel are also returned.

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.