Get Started

This short tutorial will teach you the basics of using the Language Identification API. It demonstrates how to detect the most probable language of an audio.

Assumptions

This tutorial assumes that you have a Rev AI account. If not, sign up for a free account.

Step 1: Get your access token

The first step is to generate an access token, which will enable access to the Rev AI APIs. Follow these steps:

  1. Log in to Rev AI.
  2. Navigate to the Access Token page .
  3. Click the Generate New Access Token link. Confirm the operation in the pop-up dialog box.

Creating an access token

The new access token will be generated and displayed on the screen.

warning

Save your access tokens somewhere safe; you will only be able to see them once. You are allowed a maximum of 2 access tokens at a time.

Step 2: Submit a file for language identification

Submit an audio file for language identification to Rev AI using the command below. Replace the <REVAI_ACCESS_TOKEN> placeholder with the access token obtained in Step 1, and replace the sample file URL shown below with the URL to your own audio file if required.

Copy
Copied
curl -X POST "https://api.rev.ai/languageid/v1/jobs" \
     -H "Authorization: Bearer <REVAI_ACCESS_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"source_config": {"url": "https://www.rev.ai/FTC_Sample_1.mp3"},"metadata":"This is a test"}'

You'll receive a response like this:

Copy
Copied
{
  "id": "Umx5c6F7pH7r",
  "created_on": "2021-09-15T05:14:38.13",
  "metadata": "This is a test",
  "status": "in_progress",
  "type": "language_id"
}

The id (in this case Umx5c6F7pH7r) will enable you to retrieve your language identification result.

Step 3: Retrieve the language identification results

You now need to wait for the job to complete. Wait for approximately 30 seconds and then check the status of your job by querying the API as shown below:

Copy
Copied
curl -X GET https://api.rev.ai/languageid/v1/jobs/<ID> \
     -H "Authorization: Bearer <REVAI_ACCESS_TOKEN>"
warning

Polling the API periodically for job status is NOT recommended in a production server. Rather, use webhooks to asynchronously receive notifications once the language identification job completes.

Once the job's status changes to completed, you can retrieve the results in JSON format by running the command below. As before, replace the <REVAI_ACCESS_TOKEN> placeholder with the access token obtained in Step 1. You must also replace the <ID> placeholder with the id obtained in Step 2.

The job will take approximately 5 seconds to complete when submitted using the sample file URL above.

Copy
Copied
curl -X GET "https://api.rev.ai/languageid/v1/jobs/<ID>/result" \
     -H "Authorization: Bearer <REVAI_ACCESS_TOKEN>" \
     -H "Accept: application/vnd.rev.languageid.v1.0+json"

Here is an example of the output:

Copy
Copied
{
  "top_language": "en",
  "language_confidences": [
    {
      "language": "en",
      "confidence": 0.907
    },
    {
      "language": "nl",
      "confidence": 0.023
    },
    {
      "language": "ar",
      "confidence": 0.023
    },
    {
      "language": "de",
      "confidence": 0.023
    },
    {
      "language": "cmn",
      "confidence": 0.023
    }
  ]
}

Next steps

You should now have a basic idea of how to use the Language Identification API. To learn more, read the API documentation for complete details on the different resources and operations available in this API. You can also read about our other APIs and find code samples and SDK documentation that will help you connect your application with the API.