Extract transcriptions

At a high level, extracting a transcription from a video involves the following steps:

  • Upload and index a video. When you upload a video by calling the POST method of the /tasks endpoint, the platform creates a video indexing task and returns its unique identifier.
  • Retrieve the unique identifier of your video . Once the platform finishes indexing your video, you can retrieve its unique identifier by calling the GET method of the /tasks/{task-id} endpoint and passing it the unique identifier of your video indexing task.
  • Retrieve a transcription. Call the GET method of the /indexes/{index-id}/videos/{video-id}/transcription endpoint, passing it the unique identifiers of your index and video. For a description of each field in the request and response, see the API Reference > Retrieve transcriptions page.

Prerequisites

  • You’re familiar with the concepts that are described on the Platform overview page.
  • You've uploaded a video, and the platform has finished indexing it. The unique identifier of your video is stored in a variable named VIDEO_ID. For details about uploading videos, see the Upload videos page.

Procedure

  1. Construct the URL for extracting the transcription based on the INDEX_ID and VIDEO_ID variables:

    TRANSCRIPTIONS_URL = f"{API_URL}/indexes/{INDEX_ID}/videos/{VIDEO_ID}/transcription"
    
    const TRANSCRIPTIONS_URL = `${API_URL}/indexes/${INDEX_ID}/videos/${VIDEO_ID}/transcription`
    
  2. Retrieve the transcription and print it out to the console:

    response = requests.get(TRANSCRIPTIONS_URL, headers=headers)
    print (f"Status code: {response.status_code}")
    pprint (response.json())
    
    const config = {
      method: 'get',
      url: TRANSCRIPTIONS_URL, 
      headers: headers,
    }
    const resp = await axios(config)
    const response = await resp.data
    console.log(`Status code: ${resp.status}`)
    console.log(response)
    

    The following example output was truncated for brevity:

    Status code: 200
    {
      "_id": "62aff6da154f59c87660ce9a",
      "data": [
        {
          "end": 287.05,
          "start": 280.94,
          "value": " Oh I'm so glad I was recording it."
        },
        {
          "end": 295.66,
          "start": 287.44,
          "value": " Ah ha ha ha got like a big stick or something."
        },
        { "end": 299.85, "start": 299.04, "value": " Big stick," },
        { "end": 302.81, "start": 301.54, "value": " it's heavy whatever it is." },
        { "end": 309.11, "start": 306.55, "value": " Ah that is not a stick." },
        {
          "end": 313.86,
          "start": 309.12,
          "value": " Oh my God that's not a stick at all."
        }
      ],
      "index_id": "629deb409ea24f052b971993"
    }
    

    Note that you can use the start and end query parameters to specify the time range for which you want to retrieve the transcription. The following example URL retrieves the transcription for the first 10 seconds of the video:

    TRANSCRIPTIONS_URL = f"{API_URL}/indexes/{INDEX_ID}/videos/{VIDEO_ID}/transcription?start=0&end=10"
    
    const TRANSCRIPTIONS_URL = `${API_URL}/indexes/${INDEX_ID}/videos/${VIDEO_ID}/transcription?start=0&end=10`