Skip to content
videodb
VideoDB Documentation
  • Pages
    • Welcome to VideoDB Docs
    • Quick Start Guide
      • Video Indexing Guide
      • Semantic Search
      • Collections
      • Public Collections
      • Callback Details
      • Ref: Subtitle Styles
      • Language Support
      • Guide: Subtitles
      • How Accurate is Your Search?
    • Visual Search and Indexing
      • Scene Extraction Algorithms
      • Custom Annotations
      • Scene-Level Metadata: Smarter Video Search & Retrieval
      • Advanced Visual Search Pipelines
      • Playground for Scene Extractions
      • Deep Dive into Prompt Engineering : Mastering Visual Indexing
      • How VideoDB Solves Complex Visual Analysis Tasks
      • Multimodal Search: Quickstart
      • Conference Slide Scraper with VideoDB
    • Examples and Tutorials
      • Dubbing - Replace Soundtrack with New Audio
      • VideoDB: Adding AI Generated voiceovers to silent footage
      • icon picker
        Beep curse words in real-time
      • Remove Unwanted Content from videos
      • Instant Clips of Your Favorite Characters
      • Insert Dynamic Ads in real-time
      • Adding Brand Elements with VideoDB
      • Elevating Trailers with Automated Narration
      • Add Intro/Outro to Videos
      • Audio overlay + Video + Timeline
      • Building Dynamic Video Streams with VideoDB: Integrating Custom Data and APIs
      • AI Generated Ad Films for Product Videography
      • Fun with Keyword Search
      • Overlay a Word-Counter on Video Stream
      • Generate Automated Video Outputs with Text Prompts | VideoDB
      • Multimodal Search
      • How I Built a CRM-integrated Sales Assistant Agent in 1 Hour
      • Make Your Video Sound Studio Quality with Voice Cloning
      • Automated Traffic Violation Reporter
      • VideoDB x TwelveLabs: Real-Time Video Understanding
    • Live Video→ Instant Action
    • Generative Media Quickstart
      • Generative Media Pricing
    • Video Editing Automation
      • Fit & Position: Aspect Ratio Control
      • Trimming vs Timing: Two Independent Timelines
      • Advanced Clip Control: The Composition Layer
      • Caption & Subtitles: Auto-Generated Speech Synchronization
      • Example Notebooks
    • Transcoding Quickstart
    • director-light
      Director - Video Agent Framework
      • Agent Creation Playbook
      • Setup Director Locally
    • Workflows and Integrations
      • zapier
        Zapier Integration
        • Auto-Dub Videos & Save to Google Drive
        • Create & Add Intelligent Video Highlights to Notion
        • Create GenAI Video Engine - Notion Ideas to Youtube
        • Automatically Detect Profanity in Videos with AI - Update on Slack
        • Generate and Store YouTube Video Summaries in Notion
        • Automate Subtitle Generation for Video Libraries
        • Solve customers queries with Video Answers
      • n8n
        N8N Workflows
        • AI-Powered Meeting Intelligence: Recording to Insights Automation
        • AI Powered Dubbing Workflow for Video Content
        • Automate Subtitle Generation for Video Libraries
        • Automate Interview Evaluations with AI
        • Turn Meeting Recordings into Actionable Summaries
        • Auto-Sync Sales Calls to HubSpot CRM with AI
        • Instant Notion Summaries for Your Youtube Playlist
    • Meeting Recording SDK
    • github
      Open Source
      • llama
        LlamaIndex VideoDB Retriever
      • PromptClip: Use Power of LLM to Create Clips
      • StreamRAG: Connect ChatGPT to VideoDB
    • mcp
      VideoDB MCP Server
    • videodb
      Give your AI, Eyes and Ears
      • Building Infrastructure that “Sees” and “Edits”
      • Agents with Video Experience
      • From MP3/MP4 to the Future with VideoDB
      • Dynamic Video Streams
      • Why do we need a Video Database Now?
      • What's a Video Database ?
      • Enhancing AI-Driven Multimedia Applications
      • Beyond Traditional Video Infrastructure
    • Customer Love
    • Join us
      • videodb
        Internship: Build the Future of AI-Powered Video Infrastructure
      • Ashutosh Trivedi
        • Playlists
        • Talks - Solving Logical Puzzles with Natural Language Processing - PyCon India 2015
      • Ashish
      • Shivani Desai
      • Gaurav Tyagi
      • Rohit Garg
      • Edge of Knowledge
        • Language Models to World Models: The Next Frontier in AI
        • Society of Machines
          • Society of Machines
          • Autonomy - Do we have the choice?
          • Emergence - An Intelligence of the collective
        • Building Intelligent Machines
          • Part 1 - Define Intelligence
          • Part 2 - Observe and Respond
          • Part 3 - Training a Model
      • Updates
        • VideoDB Acquires Devzery: Expanding Our AI Infra Stack with Developer-First Testing Automation

Beep curse words in real-time

Overview

VideoDB’s makes it easy to personalize content to meet users’ requirements. If users prefer not to include curse words in their content, VideoDB allows for these words to be either removed or replaced with a sound overlay such as beep sound.
This task, typically complex for video editors, can be accomplished with just a few lines of code using VideoDB.
This technique can also serve as a valuable Content Moderation component for any social content platform, ensuring that content meets the preferences and standards of its audience.
Let’s dive in!

🔗 Prerequisites

Ensure you have latest VideoDB installed in your environment. If not, simply run !pip install -U videodb in your terminal.
You'll also need a VideoDB API_KEY, which can be obtained from the VideoDB .

🌐 Connect to VideoDB

Connect to VideoDB using your API key. This establishes a session for uploading and manipulating video and audio files:
# create a new connection with your API key
import videodb
import os
from getpass import getpass

# Prompt user for API key securely
api_key = getpass("Please enter your VideoDB API Key: ")
os.environ["VIDEO_DB_API_KEY"] = api_key

from videodb import connect, play_stream
conn = connect()


📺 Source Content

For this tutorial, let's take the Joe Rogan clip, where he is trying to trick siri into using curse words 🤣
# Joe rogan video clip
video = conn.upload(url='https://www.youtube.com/watch?v=7MV6tUCUd-c')

# watch the original video
o_stream = video.generate_stream()
play_stream(o_stream)

📢 Index the video

Find out the curse words with the spoken Index.
# index spoken content in the video
video.index_spoken_words()

🎛️ Create beep Asset

We have a sample beep sound in this folder, beep.wav. For those looking to add a more playful or unique touch, replacing the beep with alternative sound effects, such as a quack or any other sound, can make the content more engaging and fun.
# Import Editor SDK components
from videodb.editor import VideoAsset, AudioAsset, Timeline, Track, Clip

# upload beep sound - This is just a sample, you can replace it with quack or any other sound effect.
beep = conn.upload(file_path="beep.wav")

# Create audio asset from beep sound
beep_asset = AudioAsset(id=beep.id)

🥷🏻 Moderation

To ensure appropriate content management, it's necessary to have a method for identifying profanity and applying a predefined overlay to censor it. In this tutorial, we've included a list of curse words. Feel free to customize this list according to your requirements.
curse_words_list = ['shit', 'ass', 'shity' 'fuck', 'motherfucker','damn', 'fucking', 'motherfuker']

🔍 Finding the Curse Words

We'll use few NLP techniques to identify all variations of any offensive words, eliminating the need to manually find and include each form. Additionally, by analyzing the transcript, you can gain insights into how these sounds are transcribed, acknowledging the possibility of errors.
#install spacy
!pip -q install spacy

#install dataset english core
!python -m spacy download en_core_web_sm

# load the english corpus
import spacy
import re
nlp = spacy.load("en_core_web_sm")

def get_root_word(word):
"""
This function convert each word into its root word
"""
try:
#clean punctuations
cleaned_word = re.sub(r'[^\w\s]', '', word)

# Process the sentence
doc = nlp(cleaned_word)

# Lemmatize the word
lemmatized_word = [token.lemma_ for token in doc][0] # Assuming single word input

return lemmatized_word
except Exception as e:
print(f"some issue with lemma for the word {word}")
return word

⏭️ Create Fresh Timeline

Let's create a timeline using the Track and Clip pattern. Add the video clip to the main track, then loop through the transcript to add beep overlays wherever curse words are detected.
# Create a new Timeline
timeline = Timeline(conn)

# Create main track with video
main_track = Track()
video_asset = VideoAsset(id=video.id)
video_clip = Clip(asset=video_asset, duration=float(video.length))
main_track.add_clip(0, video_clip)
timeline.add_track(main_track)

# Create overlay track for beep sounds
beep_track = Track()

for word in transcript:
text = word.get('text')
if text not in ['-']:
root_word = get_root_word(text)
if root_word in curse_words_list:
beep_start_time = float(word.get('start'))
beep_end_time = float(word.get('end'))
beep_duration = beep_end_time - beep_start_time

# Add beep clip at this timestamp with increased volume
print(f"beep the word: {text}, {beep_start_time}:{beep_end_time}")
beep_clip = Clip(
asset=AudioAsset(id=beep.id, start=0, volume=2.0),
duration=beep_duration
)
beep_track.add_clip(beep_start_time-0.25, beep_clip)
timeline.add_track(beep_track)
stream_url = timeline.generate_stream()

🌐 Review and Share Your Moderated Video

Finally, watch and share your new stream:
from videodb import play_stream
play_stream(stream_url)

⚡️ The Real Power of Programmable Streams

If you have videos pre-uploaded and indexed, running this beep pipeline is real-time. So, based on your users' choices or your platform's policy, you can use information from spoken content to automatically moderate.

Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.