Skip to main content

Language Identification

Transcription:Batch Deployments:SaaS

Detect the predominant language spoken and transcribe using the appropriate language.

Looking for how to deploy this on-prem? See the documentation here.

Automatic Language Identification can be set when calling the Speechmatics Transcription API. You can also try it for free in the Speechmatics portal with no code.

If you're new to Speechmatics, please see our guide on transcribing a file through our API.

Once you are set up, just set language to auto to use Automatic Language Identification:

{
  "type": "transcription",
  "transcription_config": {
    "language": "auto"
  }
}
info

To reliably identify the predominant language, the file should contain at least 60 seconds of speech in that language.

Enabling this for a transcription job will result in a small increase in the total turnaround time.

Setting expected languages

If you expect the audio to be one of a restricted set of languages, you can provide this information through the expected_languages parameter:

{
  "type": "transcription",
  "transcription_config": {
    "language": "auto"
  },
  "language_identification_config":{
    "expected_languages": ["en", "es", "de", "fr"]
  }
}

If the language detected is not in the expected_languages list, the job will be rejected.

A list of possible language codes can be found here. The following languages are not supported for language identification: Interlingua (ia), Esperanto (eo), Uyghur (ug), Cantonese (yue).

Transcription result

You can determine the language used to transcribe the file from the first word in the response results.

{
    ...
    "metadata": {
        "created_at": "2023-02-24T18:22:22.563358Z",
        "language_identification_config": {
            "expected_languages": ["en", "es", "de", "fr"]
        },
        ...
        "transcription_config": {
            "language": "auto"
        },
        "type": "transcription"
    },
    "results": [
        {
            "alternatives": [
                {
                    "confidence": 1.0,
                    "content": "It",
                    "language": "en",
                    "speaker": "UU"
                }
            ],
            "end_time": 0.72,
            "start_time": 0.6,
            "type": "word"
        },
    ...

Combining with other features

The following considerations are required when using Automatic Language Identification along with other Speechmatics features.

Custom Dictionary

Custom Dictionary can be used with Automatic Language Identification.

Be aware that the custom dictionary will be used with the selected language and some language-specific features such as sounds_like might not behave as expected.

Output locale

Output Locale is currently not supported in combination with using Automatic Language Identification. Jobs with this combination of features will be rejected.

Translation

Translation can be used with Automatic Language Identification.

If the identified transcription language and target translation language match, then the translation will contain the transcription sentences.

To reduce friction when using Automatic Language Identification, the translation target language is not validated when submitting the job. For each translation target language that is not supported for the identified language, there will be an error in the translation_errors field of the job metadata. For more information, see errors when used with translation. Note that if the language is specified and an unsupported translation target language is selected then the job will be rejected.

Error Responses

Unsupported expected language

If one or more of the expected languages are not supported, a HTTP 400 error response is returned.

Example bad config:

{
   "type":"transcription",
   "transcription_config":{
      "language":"en"
   },
   "language_identification_config":{
      "expected_languages":["zz"]
   }
}

Response:

{
    "code": 400,
    "detail": "Job config JSON is invalid. Error: Language(s) [zz] are not supported for language id",
    "error": "Job rejected"
}

Language not in expected_languages list

If the predicted language is not one of your expected languages, the job will be rejected.

In this example the expected languages are German or Spanish, but the predicted language is English.

This error is available when checking the job details.

{
    "job": {
        "config": {
            "language_identification_config": {
                "expected_languages": ["de","es"]
            },
            ...
        },
        "errors": [
            {
                "message": "The identified language 'en' is not one of the expected languages",
                "timestamp": "2023-02-27T11:57:20.321Z"
            }
        ],
        "id": "8eef82kaaa",
        "status": "rejected"
    }
}

No speech detected

If there is insufficient speech detected in the file, the job will be rejected.

In the following example, the audio file contains silence.

This error is available when checking the job details.

{
    "job": {
        "config": {
            ...
        },
        "errors": [
            {
                "message": "No speech found for language identification",
                "timestamp": "2023-02-27T11:59:20.321Z"
            }
        ],
        "id": "8wvf82kadd",
        "status": "rejected"
    }
}

Low confidence

If the confidence on the language prediction is very low then the job will be rejected.

This can occur when there is not enough speech in the file or if the file contains multiple languages in similar proportions.

This error is available when checking the job details.

{
    "job": {
        "config": {
            ...
        },
        "errors": [
            {
                "message": "Language identification could not identify any language with sufficient confidence",
                "timestamp": "2023-02-27T12:09:22.321Z"
            }
        ],
        "id": "8wvf82kadd",
        "status": "rejected"
    }
}

Language not supported for transcription

If the predicted language cannot be transcribed then the job will be rejected.

This error is available when checking the job details.

{
    "job": {
        "config": {
            ...
        },
        "errors": [
            {
                "message": "The identified language 'sw' is not supported for transcription",
                "timestamp": "2023-02-27T12:11:24.321Z"
            }
        ],
        "id": "8wvf82kadd",
        "status": "rejected"
    }
}

Language Identification fails

If in the unlikely event the Language Identification stage fails then the job will be rejected.

This error is available when checking the job details.

{
    "job": {
        "config": {
            ...
        },
        "errors": [
            {
                "message": "Language identification failed",
                "timestamp": "2023-02-27T12:19:52.321Z"
            }
        ],
        "id": "8wvf82kadd",
        "status": "rejected"
    }
}

Errors when used with Translation

It is not possible to translate between all language pairs. When auto language is used, this can mean some translation target languages will not be available. See the full list of supported language pairs.

These errors are available when getting the job transcript.

{
    ...
    "metadata": {
        "created_at": "2023-02-27T12:29:12.607814Z",
        "type": "transcription",
        "transcription_config": {
            "language": "auto"
        },
        "translation_config": {
            "target_languages": [
                "de", "nn"
            ]
        },
        "translation_errors": [
            {
                "type": "unsupported_translation_pair",
                "message": "Translation from en to nn currently not supported"
            }
        ]
    },
    ...
}