Announcements

New! Break Transcripts into Paragraphs and Sentences

In this week's update, we released two new API endpoints that you can use to pull a completed transcript broken into paragraphs and sentences!

New! Break Transcripts into Paragraphs and Sentences

A common request from developers is what to do with a massive transcription you get back from the AssemblyAI Speech-to-Text API once it has been converted successfully. Displaying the transcription text as one big text block is often not very user-friendly, and a lot of black magic logic usually gets implemented to break this wall of text into something more digestible.

To make developers' lives easier, we now have two new endpoints that allow you to pull a completed transcript broken into paragraphs, or should you desire to be more specific, sentences!

To access this new feature, there is nothing extra you have to do with your account. You don't even have to resubmit the audio! All you have to do is send a GET request to the endpoint of your choosing:

/v2/transcript/{TRANSCRIPT ID}/paragraphs
/v2/transcript/{TRANSCRIPT ID}/sentences

Here is a simple example of hitting the new /v2/transcript/{TRANSCRIPT ID}/paragraphs endpoint in Python:

import request

endpoint = 'https://api.assembly.com/v2/transcript/{TRANSCRIPT ID}/paragraphs'

headers = {'authorization': 'YOUR ASSEMBLYAI API TOKEN'}

response = requests.get(endpoint, headers=headers)

print(response.json())

And that is it! You will then get back a broken-down response into your choice of paragraphs or sentences for you to loop over and display as you wish. Here is an example response from the above Python code:

{
   "paragraphs":[
      {
         "text":"Hello. I'm Sunny Williams. I'm up here on the International Space Station. So this is No two. This is a really cool module.",
         "start":770,
         "end":10710,
         "confidence":0.97,
         "words":[
            {"text": "Hello.", "start": 100, "end": 1000, "confidence": 0.99},
            "..."
         ]
      },
      {
         "text":"Of course, most of these modules, you'll see, they have four sides and they're put together that way we could sort of work on a flat plane, either a wall, a floor, another wall, or the ceiling. But again, all you have to do is turn yourself and your reference changes. The reason I'm bringing that up is because this is where four out of six of us sleep. And so people always ask about sleeping in space. Do you lie down?",
         "start":11370,
         "end":39060,
         "confidence":0.99,
         "words":[
            {"text": "Of.", "start": 12, "end": 450, "confidence": 0.99},
            "..."
         ]
      },
      {
         "text":"Are you in a bed? Not really, because it doesn't matter. You don't really have the sensation of lying down. You just sit in your sleeping bag. So Here's one sleep station right here.",
         "start":39070,
         "end":50250,
         "confidence":0.99,
         "words":[
            {"text": "Are.", "start": 45, "end": 290, "confidence": 0.99},
            "..."
         ]
      },

        "......"

    ],
    "id": "3otc28umy-25ae-4446-b133-70e244be5208",
    "confidence": 0.951530612244907,
    "audio_duration": 521.352
}

Now you are ready to create easy to read interfaces straight from your audio file! You can read more about each endpoint in the AssemblyAI API Docs.