Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 4, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 4, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 4, 2025

      Smashing Animations Part 4: Optimising SVGs

      June 4, 2025

      I test AI tools for a living. Here are 3 image generators I actually use and how

      June 4, 2025

      The world’s smallest 65W USB-C charger is my latest travel essential

      June 4, 2025

      This Spotlight alternative for Mac is my secret weapon for AI-powered search

      June 4, 2025

      Tech prophet Mary Meeker just dropped a massive report on AI trends – here’s your TL;DR

      June 4, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Beyond AEM: How Adobe Sensei Powers the Full Enterprise Experience

      June 4, 2025
      Recent

      Beyond AEM: How Adobe Sensei Powers the Full Enterprise Experience

      June 4, 2025

      Simplify Negative Relation Queries with Laravel’s whereDoesntHaveRelation Methods

      June 4, 2025

      Cast Model Properties to a Uri Instance in 12.17

      June 4, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      My Favorite Obsidian Plugins and Their Hidden Settings

      June 4, 2025
      Recent

      My Favorite Obsidian Plugins and Their Hidden Settings

      June 4, 2025

      Rilasciata /e/OS 3.0: Nuova Vita per Android Senza Google, Più Privacy e Controllo per l’Utente

      June 4, 2025

      Rilasciata Oracle Linux 9.6: Scopri le Novità e i Miglioramenti nella Sicurezza e nelle Prestazioni

      June 4, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Artificial Intelligence»Filter profanity from audio files using Node.js

    Filter profanity from audio files using Node.js

    May 28, 2024

    With the explosion of audio and video content available online, it is hard to ensure this content does not include swear words and other profanity. With profanity detection AI models, developers can automatically filter out offensive language at scale.

    In this tutorial, you’ll learn how to use Node.js to filter profanity from audio files. By the end of this guide, you’ll be equipped to implement this functionality in just a few lines of code, enhancing both user experience and content compliance.

    Here is the audio file you will be running profanity filtering on, along with the filtered output, where the asterisks represent harmful speech that has automatically been filtered:

    Profanity filtering
    0:00
    /4.257938

    Filtering profanity from audio and video files is easy as s*** with AssemblyAI.

    Step 1: Set up your environment

    First, install Node.js 18 or higher on your system.
    Next, create a new project folder, change directories to it, and initialize a new node project:

    mkdir filter-profanity
    cd filter-profanity
    npm init -y

    Open the package.json file and add type: “module”, to the list of properties.

    {
    …
    “type”: “module”,
    …
    }

    Then, install the AssemblyAI JavaScript SDK which lets you interact with AssemblyAI API more easily:

    npm install –save assemblyai

    Next, get a free AssemblyAI API key here; or, if you already have one, you can copy your API key from your dashboard. Once you’ve copied your API key, configure it as the ASSEMBLYAI_API_KEY environment variable on your machine:

    # Mac/Linux:
    export ASSEMBLYAI_API_KEY=<YOUR_KEY>

    # Windows:
    set ASSEMBLYAI_API_KEY=<YOUR_KEY>

    Step 2: Transcribe and filter the audio file

    Now that your environment is set up, you can submit an audio file for transcription with profanity filtering. For this tutorial, you’ll be using this example file. If you want to use your own file, you can use either a local file on your system or a remote file as long as it is a publicly accessible download URL. You can also use video files.

    Create a file called index.js, and in the file, import the assemblyai package and create an AssemblyAI client.

    import { AssemblyAI } from ‘assemblyai’;

    // create AssemblyAI API client
    const client = new AssemblyAI({ apiKey: process.env.ASSEMBLYAI_API_KEY });

    Create a variable for the URL or the path to the audio file you want to filter profanity from:

    // replace with local file path or your remote file
    const audioFile = “https://storage.googleapis.com/aai-web-samples/profanity-filtering.mp3”

    Transcribe the audio file with the filter_profanity option set to true:

    // transcribe audio file with profanity filtering
    const transcript = await client.transcripts.transcribe({
    audio: audioFile,
    filter_profanity: true
    });

    Step 3: Print the filtered text

    You can print the profanity-filtered transcript text as follows:

    // throw error if transcript status is error
    if (transcript.status === “error”) {
    throw new Error(transcript.error);
    }

    // print transcript text
    console.log(transcript.text);

    Save your file and execute it by running node index.js in the project directory.

    You’ll see the profanity-filtered audio transcript printed to the terminal – if you used the default file from above you’ll see the following output printed to the terminal:

    Filtering profanity from audio and video files is easy as s*** with AssemblyAI.

    The transcript contains a lot more information about the transcribed audio file, like word-level timestamps and more, which you can access through the object’s properties. Check out the AssemblyAI docs to learn more about Transcript objects and the other information you can get back from the AssemblyAI API.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleControlled diffusion model can change material properties in images
    Next Article The Silent Sky

    Related Posts

    Security

    HPE StoreOnce Faces Critical CVE-2025-37093 Vulnerability — Urges Immediate Patch Upgrade

    June 4, 2025
    Security

    CISA Adds Qualcomm Vulnerabilities to KEV Catalog

    June 4, 2025
    Leave A Reply Cancel Reply

    Hostinger

    Continue Reading

    CodeSOD: Mr Number

    News & Updates

    Microsoft stops selling flagship Surface Pro 11 and Surface Laptop 7 for $999 — they’re now more expensive, but tariffs aren’t to blame

    News & Updates

    Login with different Login ID’s for native mobile application using JMeter

    Development

    10 Scenario-Based Terraform Interview Questions and Answers

    Linux
    Hostinger

    Highlights

    Machine Learning

    LLM Unlearning Benchmarks are Weak Measures of Progress

    April 18, 2025

    TL;DR: “Machine unlearning” aims to remove data from models without retraining the model completely. Unfortunately,…

    An IT admin found an ingenious way to silently update dozens of Windows 10 devices to Windows 11 remotely

    January 30, 2025

    Huayra is a Linux distribution based on Debian

    May 2, 2025

    Ubuntu installations on WSL 2 are now better than ever and don’t require the Microsoft Store

    February 6, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.