The Topic Detection model lets you identify different topics in the transcript. The model uses the IAB Content Taxonomy, a standardized language for content description which consists of 698 comprehensive topics.

Quickstart

Enable Topic Detection by setting iab_categories to true in the transcription parameters.

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5# audio_file = "./local_file.mp3"
6audio_file = "https://assembly.ai/wildfires.mp3"
7
8config = aai.TranscriptionConfig(iab_categories=True)
9
10transcript = aai.Transcriber().transcribe(audio_file, config)
11
12# Get the parts of the transcript that were tagged with topics
13for result in transcript.iab_categories.results:
14 print(result.text)
15 print(f"Timestamp: {result.timestamp.start} - {result.timestamp.end}")
16 for label in result.labels:
17 print(f"{label.label} ({label.relevance})")
18
19# Get a summary of all topics in the transcript
20for topic, relevance in transcript.iab_categories.summary.items():
21 print(f"Audio is {relevance * 100}% relevant to {topic}")

Open In Colab

Example output

1Smoke from hundreds of wildfires in Canada is triggering air quality alerts throughout the US. Skylines...
2Timestamp: 250 - 28920
3Home&Garden>IndoorEnvironmentalQuality (0.9881)
4NewsAndPolitics>Weather (0.5561)
5MedicalHealth>DiseasesAndConditions>LungAndRespiratoryHealth (0.0042)
6...
7Audio is 100.0% relevant to NewsAndPolitics>Weather
8Audio is 93.78% relevant to Home&Garden>IndoorEnvironmentalQuality
9...
Topic Detection Using LeMUR

Check out this cookbook Custom Topic Tags for an example of how to leverage LeMUR for custom topic detection.

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",
> "iab_categories": true
>}'
KeyTypeDescription
iab_categoriesbooleanEnable Topic Detection.

Response

KeyTypeDescription
iab_categories_resultobjectThe result of the Topic Detection model.
iab_categories_result.statusstringIs either success, or unavailable in the rare case that the Content Moderation model failed.
iab_categories_result.resultsarrayAn array of the Topic Detection results.
iab_categories_result.results[i].textstringThe text in the transcript in which the i-th instance of a detected topic occurs.
iab_categories_result.results[i].labels[j].relevancenumberHow relevant the j-th detected topic is in the i-th instance of a detected topic.
iab_categories_result.results[i].labels[j].labelstringThe IAB taxonomical label for the j-th label of the i-th instance of a detected topic, where > denotes supertopic/subtopic relationship.
iab_categories_result.results[i].timestamp.startnumberThe starting time in the audio file at which the i-th detected topic instance is discussed.
iab_categories_result.results[i].timestamp.endnumberThe ending time in the audio file at which the i-th detected topic instance is discussed.
iab_categories_result.summaryobjectSummary where each property is a detected topic.
iab_categories_result.summary.topicnumberThe overall relevance of topic to the entire audio file.

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

Frequently asked questions

The Topic Detection model uses natural language processing and machine learning to identify related words and phrases even if they are misspelled or unrecognized. However, the accuracy of the detection may depend on the severity of the misspelling or the obscurity of the word.

No, the Topic Detection model can only identify entities that are part of the IAB Taxonomy. The model is optimized for contextual targeting use cases, so using the predefined IAB categories ensures the most accurate results.

There could be several reasons why you aren’t getting any topic predictions for your audio file. One possible reason is that the audio file doesn’t contain enough relevant content for the model to analyze. Additionally, the accuracy of the predictions may be affected by factors such as background noise, low-quality audio, or a low confidence threshold for topic detection. It’s recommended to review and adjust the model’s configuration parameters and to provide high-quality, relevant audio files for analysis.

There could be several reasons why you’re getting inaccurate or irrelevant topic predictions for your audio file. One possible reason is that the audio file contains background noise or other non-relevant content that’s interfering with the model’s analysis. Additionally, the accuracy of the predictions may be affected by factors such as low-quality audio, a low confidence threshold for topic detection, or insufficient training data. It’s recommended to review and adjust the model’s configuration parameters, to provide high-quality, relevant audio files for analysis, and to consider adding additional training data to the model.

As of 2023, AssemblyAI is a partner with the Interactive Advertising Bureau (IAB), a certification and community for advertising across the internet. AssemblyAI built Topic Detection using the IAB Taxonomy, which is a blueprint of the approximately 700 topics used to categorize ads.

Built with