Skip to main content

Content Moderation

The AssemblyAI Content Moderation model detect sensitive content in audio files.


In the Identifying hate speech in audio or video files guide, the client submits an audio file and configures the API request to analyze the content for any sensitive material. The model then pinpoints the sensitive discussions and provides information on the severity to which they occurred.

You can explore the full JSON response here:


You run this code snippet in Colab here, or you can view the full source code here.

Understanding the response

The JSON object above contains all information about the transcription. Depending on which Models are used to analyze the audio, the attributes of this object will vary. For example, in the quickstart above we did not enable Summarization, which is reflected by the summarization: false key-value pair in the JSON above. Had we activated Summarization, then the summary, summary_type, and summary_model key values would contain the file summary (and additional details) rather than the current null values.

To access the Content Moderation information, we use the content_safety and content_safety_labels keys:

The reference table below lists all relevant attributes along with their descriptions, where we've called the JSON response object results. Object attributes are accessed via dot notation, and arbitrary array elements are denoted with [i]. For example, results.words[i].text refers to the text attribute of the i-th element of the words array in the JSON results object.

results.content_safetybooleanWhether Content Moderation was enabled in the transcription request
results.content_safety_labelsobjectAn object containing all results of the Content Moderation model
results.content_safety_labels.statusstringIs either success, or unavailable in the rare case that the Content Moderation model failed
results.content_safety_labels.resultsarrayAn array of objects, one for each section in the audio file that the Content Moderation file flagged
results.content_safety_labels.results[i].textstringThe transcript of the i-th section flagged by the Content Moderation model
results.content_safety_labels.results[i].labelsarrayAn array of objects, one per sensitive topic that was detected in the i-th section
results.content_safety_labels.results[i].labels[j].labelstringThe label of the sensitive topic
results.content_safety_labels.results[i].labels[j].confidencenumberThe confidence score for the j-th topic being discussed in the i-th section, from 0 to 1
results.content_safety_labels.results[i].labels[j].severitynumberHow severely the j-th topic is discussed in the i-th section, from 0 to 1
results.content_safety_labels.results[i].sentences_idx_startnumberThe sentence index at which the i-th section begins
results.content_safety_labels.results[i].sentences_idx_endnumberThe sentence index at which the i-th section ends
results.content_safety_labels.results[i].timestampobjectTimestamp information for the i-th section
results.content_safety_labels.results[i].timestamp.startnumberThe time, in milliseconds, at which the i-th section begins
results.content_safety_labels.results[i].timestamp.endnumberThe time, in milliseconds, at which the i-th section ends
results.content_safety_labels.summaryobjectA summary of the Content Moderation confidence results for the entire audio file
results.content_safety_labels.summary.topicnumberA confidence score for the presence of the sensitive topic "topic" across the entire audio file
results.content_safety_labels.severity_score_summaryobjectA summary of the Content Moderation severity results for the entire audio file
results.content_safety_labels.severity_score_summary.topic.[low, medium, high]numberA distribution across the values "low", "medium", and "high" for the severity of the presence of "topic" in the audio file.

All labels supported by the model

AccidentsAny man-made incident that happens unexpectedly and results in damage, injury, or death.accidentsYes
AlcoholContent that discusses any alcoholic beverage or its consumption.alcoholYes
Company FinancialsContent that discusses any sensitive company financial information.financialsNo
Crime ViolenceContent that discusses any type of criminal activity or extreme violence that is criminal in nature.crime_violenceYes
DrugsContent that discusses illegal drugs or their usage.drugsYes
GamblingIncludes gambling on casino-based games such as poker, slots, etc. as well as sports betting.gamblingYes
Hate SpeechContent that's a direct attack against people or groups based on their sexual orientation, gender identity, race, religion, ethnicity, national origin, disability, etc.hate_speechYes
Health IssuesContent that discusses any medical or health-related problems.health_issuesYes
MangaMangas are comics or graphic novels originating from Japan with some of the more popular series being "Pokemon", "Naruto", "Dragon Ball Z", "One Punch Man", and "Sailor Moon".mangaNo
MarijuanaThis category includes content that discusses marijuana or its usage.marijuanaYes
Natural DisastersPhenomena that happens infrequently and results in damage, injury, or death. Such as hurricanes, tornadoes, earthquakes, volcano eruptions, and firestorms.disastersYes
Negative NewsNews content with a negative sentiment which typically occur in the third person as an unbiased recapping of events.negative_newsNo
NSFW (Adult Content)Content considered "Not Safe for Work" and consists of content that a viewer would not want to be heard/seen in a public environment.nsfwNo
PornographyContent that discusses any sexual content or material.pornographyYes
ProfanityAny profanity or cursing.profanityYes
Sensitive Social IssuesThis category includes content that may be considered insensitive, irresponsible, or harmful to certain groups based on their beliefs, political affiliation, sexual orientation, or gender identity.sensitive_social_issuesNo
TerrorismIncludes terrorist acts as well as terrorist groups. Examples include bombings, mass shootings, and ISIS. Note that many texts corresponding to this topic may also be classified into the crime violence topic.terrorismYes
TobaccoText that discusses tobacco and tobacco usage, including e-cigarettes, nicotine, vaping, and general discussions about smoking.tobaccoYes
WeaponsText that discusses any type of weapon including guns, ammunition, shooting, knives, missiles, torpedoes, etc.weaponsYes

Adjusting the confidence threshold

The confidence threshold for content moderation results is set to 50% by default, meaning that any label with a confidence score equal to or higher than 50% is returned. If you want to set a higher or lower threshold, you can include the content_safety_confidence parameter in your request. This parameter accepts an integer value between 25 and 100, allowing you to fine-tune the threshold to your specific needs.


Why is the Content Moderation model not detecting sensitive content in my audio file?

There could be a few reasons for this. First, make sure that the audio file contains speech, and not just background noise or music. Additionally, the model may not have been trained on the specific type of sensitive content you're looking for. If you believe the model should be able to detect the content but it's not, you can reach out to AssemblyAI's support team for assistance.

Why is the Content Moderation model flagging content that isn't actually sensitive?

The model may occasionally flag content as sensitive that isn't actually problematic. This can happen if the model isn't trained on the specific context or nuances of the language being used. In these cases, you can manually review the flagged content and determine if it's actually sensitive or not. If you believe the model is consistently flagging content incorrectly, you can contact AssemblyAI's support team to report the issue.

How do I know which specific parts of the audio file contain sensitive content?

The Content Moderation model provides segment-level results that pinpoint where in the audio the sensitive content was discussed, as well as the degree to which it was discussed. You can access this information in the results key of the API response. Each result in the list contains a text key that shows the sensitive content, and a labels key that shows the detected sensitive topics along with their confidence and severity scores.

Can the Content Moderation model be used in real-time applications?

The model is designed to process batches of segments in significantly less than 1 second, making it suitable for real-time applications. However, keep in mind that the actual processing time depends on the length of the audio file and the number of segments it's divided into. Additionally, the model may occasionally require additional time to process particularly complex or long segments.

Why am I receiving an error message when using the Content Moderation model?

If you receive an error message, it may be due to an issue with your request format or parameters. Double-check that your request includes the correct audio_url parameter. If you continue to experience issues, you can reach out to AssemblyAI's support team for assistance.