The Audio Profanity Model helps you determine if a video or audio file contains profanity such as insults, discriminatory content, sexual content or otherwise inappropriate words or phrases.
Profanity Detection is done in English by default. To inquire about other languages please reach out.
Audio profanity works by analyzing your file's audio tracks. If you need to detect written profanity in videos or images, you should use our Text Moderation in Videos instead.
In this guide, you will learn how to moderate audio in stored videos and stored audio files
If you haven't already, create an account to get your own API keys.
To moderate the audio part of a stored video, just add audio-profanity to the model parameter in your API calls. You can of course add multiple models at the same time, for instance if you want to detect things like nudity or graphic content along with spoken profanity. Head to the Model Reference for the full list of available models.
To moderate a video, you can either send a public URL pointing to this video or send the video's raw bytes. Here's how to proceed to send the raw bytes:
curl -X POST 'https://api.sightengine.com/1.0/video/check-sync.json' \
-F 'media=@/path/to/file.mp4' \
-F 'models=audio-profanity' \
-F 'api_user={api_user}' \
-F 'api_secret={api_secret}'
# this example uses requests
import requests
import json
params = {
# specify the models you want to apply
'models': 'audio-profanity',
'api_user': '{api_user}',
'api_secret': '{api_secret}'
}
files = {'media': open('/path/to/file.mp4', 'rb')}
r = requests.post('https://api.sightengine.com/1.0/video/check-sync.json', files=files, data=params)
output = json.loads(r.text)
$params = array(
'media' => new CurlFile('/path/to/file.mp4'),
// specify the models you want to apply
'models' => 'audio-profanity',
'api_user' => '{api_user}',
'api_secret' => '{api_secret}',
);
// this example uses cURL
$ch = curl_init('https://api.sightengine.com/1.0/video/check-sync.json');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$response = curl_exec($ch);
curl_close($ch);
$output = json_decode($response, true);
// this example uses axios and form-data
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
data = new FormData();
data.append('media', fs.createReadStream('/path/to/file.mp4'));
// specify the models you want to apply
data.append('models', 'audio-profanity');
data.append('api_user', '{api_user}');
data.append('api_secret', '{api_secret}');
axios({
method: 'post',
url:'https://api.sightengine.com/1.0/video/check-sync.json',
data: data,
headers: data.getHeaders()
})
.then(function (response) {
// on success: handle response
console.log(response.data);
})
.catch(function (error) {
// handle error
if (error.response) console.log(error.response.data);
else console.log(error.message);
});
Moderation will happen while you wait for the API response. Once moderation has been done, the API will return a JSON response containing a description of any profanity found.
If a video contains profanity, it will be reflected in the profanity field in the API response. Here is an example response, assuming that the word "shit" was found:
{
"status": "success",
"request": {
"id": "req_1OjggusalNb2S7MxwLq2h",
"timestamp": 1509132120.6988,
"operations": 5
},
"media": {
"id": "med_1OjgEqvJtOhqP7sfNe3ga",
"uri": "/path/to/file.mp4"
},
"data": {
"audio": {
"profanity": [
{
"type": "inappropriate",
"match": "shit",
"start_ms": 4918,
"end_ms": 5230
}
]
}
}
}
For each match, you will get the matching string, the profanity type, and corresponding timestamps (start_ms and end_ms) expressed in milliseconds. The profanity type can be any of the following: sexual inappropriate discriminatory insult other_profanity.
If a video does not contain any profanity, then an empty profanity array will be returned. Here is an example:
{
"status": "success",
"request": {
"id": "req_1OjggusalNb2S7MxwLq2h",
"timestamp": 1509132120.6988,
"operations": 5
},
"media": {
"id": "med_1OjgEqvJtOhqP7sfNe3ga",
"uri": "/path/to/file.mp4"
},
"data": {
"audio": {
"profanity": []
}
}
}
See our full list of Image/Video models for details on other filters and checks you can run on your images and videos. You might also want to check our Text models to moderate text-based content: messages, reviews, comments, usernames...
Was this page helpful?