Identifying hate speech in audio or video files
In this guide, we'll explore the various labels available through Content Moderation, and offer best practices for using this tool to ensure your content is safe and appropriate for all audiences.
Create a new file and import the necessary libraries for making an HTTP request.
Set up the API endpoint and headers. The headers should include your API token.
Upload your local file to the AssemblyAI API.
upload_urlreturned by the AssemblyAI API to create a JSON payload containing the
POSTrequest to the AssemblyAI API endpoint with the payload and headers.
After making the request, you will receive an ID for the transcription. Use it to poll the API every few seconds to check the status of the transcript job. Once the status is
completed, you can retrieve the transcript from the API response.
Understanding the response
In the JSON response, there will be an additional key called
content_safety_labels that contains information about any sensitive content detected. The full text will be contained in the
text key, and each problematic utterance will have its own
timestamp. The entire audio will be assigned a
summary and a
severity_score_summary for each category of unsafe content. Each label will be returned with a confidence score and a severity score.
For more information, see the content moderation model documentation or refer to the API reference.
The AssemblyAI API supports many different content safety labels. Identifying hate speech is only a single, important use case for automated content moderation, and you can learn about others on the AssemblyAI blog.