• Contact Us
  • Privacy Policy
  • Terms of Use
  • DMCA
  • Disclaimer
Monday, December 15, 2025
CryptoBangs.com
Advertisement
  • Home
  • Live Crypto Prices
  • Crypto News
    • Bitcoin
    • Ethereum
    • Ripple
    • Altcoin
    • NFT News
  • DeFi
  • Blockchain
  • Regulation
  • Shop
  • Blog
  • Calculator
No Result
View All Result
  • Home
  • Live Crypto Prices
  • Crypto News
    • Bitcoin
    • Ethereum
    • Ripple
    • Altcoin
    • NFT News
  • DeFi
  • Blockchain
  • Regulation
  • Shop
  • Blog
  • Calculator
No Result
View All Result
CryptoBangs.com
No Result
View All Result

Creating WebVTT Files for Videos Using Node.js: A Comprehensive Guide

June 18, 2024
in Blockchain
Reading Time: 2 mins read
A A
Creating WebVTT Files for Videos Using Node.js: A Comprehensive Guide
ShareShareShareShareShare





WebVTT (.vtt) or Web Video Text Tracks Format is a widely supported format for subtitles in videos. In this guide, you’ll learn how to create WebVTT files for videos using Node.js and the AssemblyAI API, according to AssemblyAI.

Step 1: Set Up Your Development Environment

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

Related articles

Pepe Price Plunges As This Rival Raises Over $3.5M In Presale

Pepe Price Plunges As This Rival Raises Over $3.5M In Presale

December 10, 2024
Riot Platforms (RIOT) Launches $525 Million Convertible Notes Offering

Riot Platforms (RIOT) Launches $525 Million Convertible Notes Offering

December 10, 2024
mkdir vtt-subtitles
cd vtt-subtitles
npm init -y

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

{
  ...
  "type": "module",
  ...
}

This will tell Node.js to use the ES Module syntax for exporting and importing modules. Then, install the AssemblyAI JavaScript SDK:

npm install --save assemblyai

Next, obtain an AssemblyAI API key from your dashboard. Set it as the ASSEMBLYAI_API_KEY environment variable:

# Mac/Linux:
export ASSEMBLYAI_API_KEY=<YOUR_KEY>

# Windows:
set ASSEMBLYAI_API_KEY=<YOUR_KEY>

Step 2: Transcribe Your Video

With the development environment ready, start transcribing your video files. Use this sample video for practice. Create a file called index.js and add the following code:

import { AssemblyAI } from 'assemblyai';

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

const transcript = await client.transcripts.transcribe({
  audio: "https://storage.googleapis.com/aai-web-samples/aai-overview.mp4",
});

If the transcription is successful, the transcript object will be populated. Verify and log any errors:

if (transcript.status === "error") {
  throw new Error(transcript.error);
}

Step 3: Generate WebVTT File

Generate the subtitles in WebVTT format. Import the necessary module to save the WebVTT file to disk:

import { writeFile } from "fs/promises"

Add the following code to generate and download the VTT file:

const vtt = await client.transcripts.subtitles(transcript.id, "vtt");
await writeFile("./subtitles.vtt", vtt);

Customize the maximum number of characters per caption if needed:

const vtt = await client.transcripts.subtitles(transcript.id, "vtt", 32);
await writeFile("./subtitles.vtt", vtt);

Step 4: Run the Script

Run the script from your shell:

node index.js

After execution, you’ll find a new file subtitles.vtt on disk:

WEBVTT

00:00.200 --> 00:04.430
AssemblyAI is building AI systems to help you build AI applications with

00:04.462 --> 00:08.694
spoken data. We create superhuman AI models for speech recognition,

00:08.774 --> 00:13.062
summarization, knowledge, augmentation of large language models with spoken

Next Steps

Now that you have your subtitle file, you can configure it in your video player or upload it to YouTube Studio. Additionally, explore other tools to bundle or burn subtitles into your video. Check out AssemblyAI’s Audio Intelligence models and LeMUR for more capabilities in your audio and video applications.

For more educational content, visit the AssemblyAI blog or their YouTube channel.

Image source: Shutterstock



Credit: Source link

ShareTweetSendPinShare
Previous Post

Innovate Change Reviews Innovative Features in New Crypto Casino Platforms

Next Post

Pepe Price Prediction: PEPE Plummets 11% As Experts Say Consider This P2E Dogecoin Derivative For 10X Gains

Related Posts

Pepe Price Plunges As This Rival Raises Over $3.5M In Presale

Pepe Price Plunges As This Rival Raises Over $3.5M In Presale

December 10, 2024

Join Our Telegram channel to stay up to date on breaking news coverage The Pepe price plunged over 12% in...

Riot Platforms (RIOT) Launches $525 Million Convertible Notes Offering

Riot Platforms (RIOT) Launches $525 Million Convertible Notes Offering

December 10, 2024

Darius Baruo Dec 10, 2024 06:18 Riot Platforms announces a $525 million offering of 0.75% convertible...

Bitfarms to Restate Financials Following SEC Review of Digital Asset Proceeds

Bitfarms to Restate Financials Following SEC Review of Digital Asset Proceeds

December 10, 2024

Peter Zhang Dec 10, 2024 06:02 Bitfarms Ltd. will restate its financial statements for 2022 and...

Top Cryptocurrencies to Buy Now December 9 – Stellar, Litecoin, Cardano

Top Cryptocurrencies to Buy Now December 9 – Stellar, Litecoin, Cardano

December 9, 2024

Join Our Telegram channel to stay up to date on breaking news coverage The cryptocurrency market has experienced notable activity,...

NexBridge Raises $30 Million with Tokenized US Treasury Offering

NexBridge Raises $30 Million with Tokenized US Treasury Offering

December 9, 2024

Joerg Hiller Dec 09, 2024 17:09 NexBridge, a digital asset issuer in El Salvador, successfully raises...

Load More
Next Post
Pepe Price Prediction: PEPE Plummets 11% As Experts Say Consider This P2E Dogecoin Derivative For 10X Gains

Pepe Price Prediction: PEPE Plummets 11% As Experts Say Consider This P2E Dogecoin Derivative For 10X Gains

No Content Available
CryptoBangs.com

CryptoBangs.com is an online news portal that aims to share the latest crypto news, bitcoin, altcoin, blockchain, nft news and much more stuff like that.

What’s New Here!

  • Tucker Carlson and Roger Ver Reveal Shocking Details About US Extradition Battle and Bitcoin in Exclusive TCN Interview
  • Goldman Sachs eyeing crypto market-making for Bitcoin, Ethereum if US regulations shift
  • BC.GAME Announces UFC Welterweight Champion Colby Covington as New Brand Ambassador
  • How High Will Dogecoin Rise If the Markets ‘Go Wild’?

Newsletter

Don't miss a beat and stay up to date with our Newsletter!
Loading

  • Contact Us
  • Privacy Policy
  • Terms of Use
  • DMCA
  • Disclaimer

© 2023 - CryptoBangs.com - All Rights Reserved!

No Result
View All Result
  • Home
  • Live Crypto Prices
  • Crypto News
    • Bitcoin
    • Ethereum
    • Ripple
    • Altcoin
    • NFT News
  • DeFi
  • Blockchain
  • Regulation
  • Shop
  • Blog
  • Calculator

© 2018 JNews by Jegtheme.

Please enter CoinGecko Free Api Key to get this plugin works.
WP Twitter Auto Publish Powered By : XYZScripts.com