Text Summarization API#

This service exposes the best performing summarization models from a variety of different vendors.

Time to Integrate#

Less than 1 minute

Service Providers#

You can find a list of all service providers here: slashml.TextSummarization.ServiceProvider

Instructions#

  1. Copy your text and pass it in the body of a POST request to https://api.slashml.com/speech-to-text/v1/jobs/. The body should contain a json object with text field. Which contains the body of the text that you want to summarize. Save the id in the response object.

  2. Check the status of the transcription by sending a GET request to https://api.slashml.com/speech-to-text/v1/jobs/

Code Blocks#

Submit text input for summarization#

If your audio files aren’t accessible via a URL already (like in an S3 bucket, or a static file server), you can upload your audio file using this API. All uploads are immediately deleted after transcription, we do not store the uploads.

POST https://api.slashml.com/summarization/v1/summarize/

Request#

import requests

  url = 'https://api.slashml.com/speech-to-text/v1/jobs/'

  payload = {
  "text":

  '''One reason programmers dislike meetings so much is that they're on a different type of schedule from other people. Meetings cost them more.

  There are two types of schedule, which I'll call the manager's schedule and the maker's schedule. The manager's schedule is for bosses. It's embodied in the traditional appointment book, with each day cut into one hour intervals. You can block off several hours for a single task if you need to, but by default you change what you're doing every hour.''',

  "service_provider": "openai"
  }

  headers = {
      "Authorization": "Token <YOUR_API_KEY>",
  }

  response = requests.post(url, headers=headers, data=payload)

  print(response.text)

Response (200)#

{
    # keep track of this id for later
    "id": "94f52a16-f2d9-4212-be98-ac87eb068d22",
    "status": "IN_PROGRESS",
    "created": "2022-12-24T01:14:18.543943Z"
}

Response (400)#

{
    "error" : {
        "message" : "something bad happened"
    }
}

Note: The ‘id’ will be used to fetch the status of the summarization job.

Check status of job#

The request API is similar to all job submissions. We can make requests to GET the status of the jobs, and eventually the result of the submitted job, i.e. transcription, or speechification.

GET https://api.slashml.com/speech-to-text/v1/jobs/YOUR-JOB-ID/

Request#

import requests

url = 'https://api.slashml.com/speech-to-text/v1/jobs/YOUR-JOB-ID/?service_provider=assembly'

headers = {
  'Authorization': 'Token <YOUR_API_KEY>'
}

response = requests.get(url, headers=headers, data=payload)
print(response.text)

Response (200) - In Progress#

{
    # keep track of the id for later
    "id": "ozfv3zim7-9725-4b54-9b71-f527bc21e5ab",
    # note that the status is now "processing"
    "status": "IN_PROGESS",
    "acoustic_model": "assemblyai_default",
    "language_model": "assemblyai_default",
    "audio_duration": null,
    "audio_url": "https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3",
    "confidence": null,
    "dual_channel": null,
    "text": null,
    "words": null
}

Response (200) - Completed#

{
    "id": "5551722-f677-48a6-9287-39c0aafd9ac1",
    "status": "COMPLETED",
    "acoustic_model": "assemblyai_default",
    "language_model": "assemblyai_default",
    "audio_duration": 12.0960090702948,
    "audio_url": "https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3",
    "confidence": 0.956,
    "dual_channel": null,
    "text": "You know Demons on TV like that and and for people to expose themselves to being rejected on TV or humiliated by fear factor or.",
    "words": [
        {
            "confidence": 1.0,
            "end": 440,
            "start": 0,
            "text": "You"
        },
        ...
        {
            "confidence": 0.96,
            "end": 10060,
            "start": 9600,
            "text": "factor"
        },
        {
            "confidence": 0.97,
            "end": 10260,
            "start": 10080,
            "text": "or."
        }
    ]
}

Response (400) - Error#

{
    "error" : {
        "message" : "something bad happened"
    }
}

Note: The status will go from ‘QUEUED’ to ‘IN_PROGRESS’ to ‘COMPLETED’. If there’s an error processing your input, the status will go to ‘ERROR’ and there will be an ‘ERROR’ key in the response JSON which will contain more information.