Filter profanity from audio information utilizing Node.js

With the explosion of audio and video content material accessible on-line, it’s exhausting to make sure this content material doesn’t embody swear phrases and different profanity. With profanity detection AI fashions, builders can mechanically filter out offensive language at scale.
In this tutorial, you’ll be taught easy methods to use Node.js to filter profanity from audio information. By the top of this information, you may be geared up to implement this performance in only a few strains of code, enhancing each consumer expertise and content material compliance.
Here is the audio file you’ll be working profanity filtering on, together with the filtered output, the place the asterisks signify dangerous speech that has mechanically been filtered:
Filtering profanity from audio and video information is simple as s*** with AssemblyAI.
Step 1: Set up your surroundings
First, set up Node.js 18 or increased in your system.
Next, create a brand new undertaking folder, change directories to it, and initialize a brand new node undertaking:
mkdir filter-profanity
cd filter-profanity
npm init -y
Open the package deal.json file and add sort: "module", to the checklist of properties.
{
...
"sort": "module",
...
}
Then, set up the AssemblyAI JavaScript SDK which helps you to work together with AssemblyAI API extra simply:
npm set up --save assemblyai
Next, get a free AssemblyAI API key right here; or, if you have already got one, you possibly can copy your API key out of your dashboard. Once you’ve copied your API key, configure it because the ASSEMBLYAI_API_KEY surroundings variable in 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 surroundings is ready up, you possibly can submit an audio file for transcription with profanity filtering. For this tutorial, you may be utilizing this instance file. If you need to use your personal file, you should utilize both an area file in your system or a distant file so long as it’s a publicly accessible obtain URL. You can even use video information.
Create a file referred to as index.js, and within the file, import the assemblyai package deal and create an AssemblyAI consumer.
import { AssemblyAI } from 'assemblyai';
// create AssemblyAI API consumer
const consumer = new AssemblyAI({ apiKey: course of.env.ASSEMBLYAI_API_KEY });
Create a variable for the URL or the trail to the audio file you need to filter profanity from:
// exchange with native file path or your distant file
const audioFile = "https://storage.googleapis.com/aai-web-samples/profanity-filtering.mp3"
Transcribe the audio file with the filter_profanity choice set to true:
// transcribe audio file with profanity filtering
const transcript = await consumer.transcripts.transcribe({
audio: audioFile,
filter_profanity: true
});
Step 3: Print the filtered textual content
You can print the profanity-filtered transcript textual content as follows:
// throw error if transcript standing is error
if (transcript.standing === "error") {
throw new Error(transcript.error);
}
// print transcript textual content
console.log(transcript.textual content);
Save your file and execute it by working node index.js within the undertaking listing.
You’ll see the profanity-filtered audio transcript printed to the terminal – when you used the default file from above you’ll see the next output printed to the terminal:
Filtering profanity from audio and video information is simple as s*** with AssemblyAI.
The transcript incorporates much more details about the transcribed audio file, like word-level timestamps and extra, which you’ll entry by way of the item’s properties. Check out the AssemblyAI docs to be taught extra about Transcript objects and the opposite data you will get again from the AssemblyAI API.
HI-FI News
through News, Tutorials, AI Research https://ift.tt/cgsWmVf
May 28, 2024 at 08:02PM
-
Product on sale
Audiophile Vinyl Records Cleaning BundleOriginal price was: €83.88.€73.88Current price is: €73.88. incl. VAT -
Product on sale
Easy Start Vinyl Records Cleaning KitOriginal price was: €83.88.€73.88Current price is: €73.88. incl. VAT -
Vinyl Records Cleaner Easy Groove Concentrate€41.94 incl. VAT -
Easy Groove Super Set€238.80 incl. VAT -
Easy Groove Enzycaster – vinyl records prewash cleaner€41.94 incl. VAT -
Easy Groove Extreme MK. II- vinyl records prewash cleaner€54.00 incl. VAT -
Vinyl Records Cleaner – Easy Groove Virgin Concentrate€42.00 incl. VAT -
Easy Groove Spray&Wipe vinyl records cleaner€41.94 incl. VAT








