Quickstart

Enable Key Phrases by setting auto_highlights to true in the transcription config.

import assemblyai as aai

aai.settings.api_key = "YOUR_API_KEY"

# audio_file = "./local_file.mp3"
audio_file = "https://assembly.ai/wildfires.mp3"

config = aai.TranscriptionConfig(auto_highlights=True)

transcript = aai.Transcriber().transcribe(audio_file, config)

for result in transcript.auto_highlights.results:
    print(f"Highlight: {result.text}, Count: {result.count}, Rank: {result.rank}, Timestamps: {result.timestamps}")

Example output

Highlight: air quality alerts, Count: 1, Rank: 0.08, Timestamps: [Timestamp(start=3978, end=5114)]
Highlight: wide ranging air quality consequences, Count: 1, Rank: 0.08, Timestamps: [Timestamp(start=235388, end=238838)]
Highlight: more fires, Count: 1, Rank: 0.07, Timestamps: [Timestamp(start=184716, end=185186)]
...

API reference

Request

curl https://api.assemblyai.com/v2/transcript \
--header "Authorization: YOUR_API_KEY" \
--header "Content-Type: application/json" \
--data '{
  "audio_url": "YOUR_AUDIO_URL",
  "auto_highlights": true
}'
KeyTypeDescription
auto_highlightsbooleanEnable Key Phrases.

Response

{
  "auto_highlights_result": {
    "status": "success",
    "results": [...]
  }
}
KeyTypeDescription
auto_highlights_resultobjectThe result of the Key Phrases model.
auto_highlights_result.statusstringIs either success, or unavailable in the rare case that the Key Phrases model failed.
auto_highlights_result.resultsarrayA temporally-sequential array of key phrases.
auto_highlights_result.results[i].countnumberThe total number of times the i-th key phrase appears in the audio file.
auto_highlights_result.results[i].ranknumberThe total relevancy to the overall audio file of this key phrase. A greater number means that the key phrase is more relevant.
auto_highlights_result.results[i].textstringThe text itself of the key phrase.
auto_highlights_result.results[i].timestamps[j].startnumberThe starting time of the j-th appearance of the i-th key phrase.
auto_highlights_result.results[i].timestamps[j].endnumberThe ending time of the j-th appearance of the i-th key phrase.

The response also includes the request parameters used to generate the transcript.

Frequently Asked Questions