Getting Automatic Captions


By Invite Only: This is not available by default. Please contact Support to enable it.
This quickstart demonstrates how to load an audio file and request captions in just a matter of minutes.

Configuring Your Environment

While you can use any programming language you choose, we provide a few helper libraries to get you started. In most cases, you can use your favorite package manager:

  • curl
Although we don't have a curl library, the command-line JSON parser 'jq' is super helpful. Download and install it to get started: http://stedolan.github.io/jq/

Loading Audio

First include the SDK and create your object using your API Key. Once you’ve created the object, you can use the object to load each of your audio files as shown:

  • curl
curl --data "media_url=http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3" \
     --data "notify_url=http://example.org/sample-receiver" \
     --data "name=Dorothy and the Wizard of Oz" https://api.clarify.io/v1/bundles \
     --X POST --header "Authorization: Bearer myapikey" | jq '.'
# The jq portion is optional and just used to pretty print the resulting json

Naming the bundle and providing a notify_url are both optional. We have a number of audio and video files available for processing on our Media Page.

Note: You don't have to download these files. Instead you can pass the urls via the create/POST method shown above.
After creating a bundle, you'll receive a response which looks something like this:
{
    "id":"abcde12345",
    "_class":"Ref",
    "_links":{
        "self":{
            "href":"/v1/bundles/abcde12345"
        },
        "curies":[
            {
                "href":"/docs/rels/{rel}",
                "name":"clarify",
                "templated":true
            }
        ],
        "clarify:metadata":{
            "href":"/v1/bundles/abcde12345/metadata"
        },
        "clarify:tracks":{
            "href":"/v1/bundles/abcde12345/tracks"
        },
        "clarify:insights":{
            "href":"/v1/bundles/abcde12345/insights"
        }
    }
}

Requesting Captions

Normally, your app will be configured to automatically run captions so you can skip right to the Getting your Captions section. If not, you can request captions to be run for an existing bundle with the following:
  • curl
curl --data "insight=captions_r4" https://api.clarify.io/v1/bundles/abcde12345/insights \
     --header "Authorization: Bearer myapikey" | jq '.'
# The jq portion is optional and just used to pretty print the resulting json
The captions may take a minute or two to generate.

Getting your Captions

From a bundle, you can use the href of the clarify:insights key. By retrieving the contents of that URI, Clarify will give you a list of the Insights available. This gives you a master list of all insights currently available to you for that bundle. It's worth noting that this list will change over time as we add new insights to the system.
{
    "bundle_id": "abcde12345",
    "created": "2015-03-04T05:03:04.292Z",
    "updated": "2015-05-16T20:39:37.508Z",
    "_class": "Insights",
    "_links": {
        "curies": [
            {
                "href": "/docs/insights/{rel}",
                "name": "insight",
                "templated": true
            }
        ],
        "insight:spoken_keywords": {
            "href": "/v1/bundles/abcde12345/insights/54321edcba"
        },
        "insight:classification": {
            "href": "/v1/bundles/abcde12345/insights/edcba56789"
        },
        "insight:spoken_words": {
            "href": "/v1/bundles/abcde12345/insights/12345abcde"
        },
        "insight:captions_r4": {
            "href": "/v1/bundles/abcde12345/insights/98765abcde"
        },
        "parent": {
            "href": "/v1/bundles/abcde12345"
        },
        "self": {
            "href": "/v1/bundles/abcde12345/insights"
        }
    }
}
In this list, the href of the insight:captions_r4 is the important part. By retrieving the contents of that URI, Clarify will give you a complete list of the available file formats for your captions.
  • curl
curl https://api.clarify.io/v1/bundles/abcde12345/insights/fadbe23456 \
    --header "Authorization: Bearer myapikey"  | jq '.'
# The jq portion is optional and just used to pretty print the resulting json
The resulting payload includes individual links to all of the available closed captioning formats. Here's the full response:
{
    "id": "fadbe23456",
    "bundle_id": "abcde12345",
    "name": "captions_r4",
    "status": "ready",
    "created": "2015-12-20T15:47:20.459Z",
    "updated": "2015-12-20T16:00:56.298Z",
    "track_data": [
        {}
    ],
    "_class": "CaptionsR4Insight",
    "_links": {
        "self": {
            "href": "/v1/bundles/abcde12345/insights/fadbe23456"
        },
        "curies": [
            {
                "href": "/docs/rels/{rel}",
                "name": "clarify",
                "templated": true
            },
            {
                "href": "/docs/insights/captions/{rel}",
                "name": "captions",
                "templated": true
            }
        ],
        "parent": {
            "href": "/v1/bundles/abcde12345/insights"
        },
        "clarify:bundle": {
            "href": "/v1/bundles/abcde12345"
        },
        "captions:vtt": [
            {
                "href": "/v1/bundles/abcde12345/insights/fadbe23456/_links?rel=captions%3Avtt&track_id=badee12345",
                "name": "badee12345"
            }
        ],
        "captions:srt": [
            {
                "href": "/v1/bundles/abcde12345/insights/fadbe23456/_links?rel=captions%3Asrt&track_id=badee12345",
                "name": "badee12345"
            }
        ]
    }
}
You can now retrieve any of the closed captioning formats you need. In this request, we'll retrieve the SRT or SubRip format:
  • curl
curl -L https://api.clarify.io/v1/bundles/abcde12345/insights/fadbe23456/_links?rel=captions%3Asrt&track_id=badee12345 \
    --header "Authorization: Bearer myapikey"  | jq '.'
# -L is required to follow redirects
# The jq portion is optional and just used to pretty print the resulting json
When making the captions file request, make sure to follow any redirects. From here, you can load the resulting file into your video player or your favorite media management platform such as Brightcove or Vimeo. At this point, it's up to you.
By Invite Only: This is not available by default. Please contact Support to enable it.
Fork me on GitHub