Getting your Keywords


This quickstart demonstrates how to load an audio file and request your spoken keywords 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"
        }
    }
}

Getting your Keywords

The most important part of the bundle notification is the href of the clarify:insights key. By retrieving the contents of that URI, Clarify will give you a list of the Insights available.
  • curl
curl 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
This will return with the list of available insights:
{
    "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:spoken_topics": {
            "href": "/v1/bundles/abcde12345/insights/34567abcde"
        },
        "insight:transcript_r4": {
            "href": "/v1/bundles/abcde12345/insights/98765abcde"
        },
        "parent": {
            "href": "/v1/bundles/abcde12345"
        },
        "self": {
            "href": "/v1/bundles/abcde12345/insights"
        }
    }
}
The most important part of this payload is the href of the insight:spoken_keywords key. By retrieving the contents of that URI, Clarify will give you the top 20 keywords recognized from the audio.
  • curl
curl https://api.clarify.io/v1/bundles/abcde12345/insights/54321edcba \
    --header "Authorization: Bearer myapikey"  | jq '.'
# The jq portion is optional and just used to pretty print the resulting json
The final result of which is our list of keywords:
{
    "bundle_id": "abcde12345",
    "created": "2015-05-16T20:39:37.507Z",
    "id": "54321edcba",
    "name": "spoken_keywords",
    "status": "ready",
    "track_data": [
        {
            "track_id": "fff111",
            "track_label": "",
            "keywords": [
                {
                    "count": 11,
                    "term": "horse",
                    "weight": 0.917
                }, {
                    "count": 9,
                    "term": "uncle",
                    "weight": 0.75
                }, {
                    "count": 7,
                    "term": "dorothy",
                    "weight": 0.583
                }, {
                    "count": 5,
                    "term": "little",
                    "weight": 0.417
                }, {
                    "count": 4,
                    "term": "train",
                    "weight": 0.333
                }
            ]
        }
    ],
    "updated": "2015-05-16T20:39:37.508Z",
    "_class": "SpokenKeywordsInsight",
    "_links": {
        "clarify:bundle": {
            "href": "/v1/bundles/abcde12345"
        },
        "curies": [
            {
                "href": "/docs/rels/{rel}",
                "name": "clarify",
                "templated": true
            }
        ],
        "parent": {
            "href": "/v1/bundles/abcde12345/insights"
        },
        "self": {
            "href": "/v1/bundles/abcde12345/insights/54321edcba"
        }
    }
}
From here, we can process the keywords just like any other JSON array. You may want to use them to perform informed searches, display word clouds, or tag your media. At this point, it's up to you.
Fork me on GitHub