• Contact Us
  • Privacy Policy
  • Terms of Use
  • DMCA
  • Disclaimer
Tuesday, June 18, 2024
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

6 Best Altcoins to Buy Now June 17 – Dogwifnohat, Kendu Inu, Merlin Chain, Cardano 

6 Best Altcoins to Buy Now June 17 – Dogwifnohat, Kendu Inu, Merlin Chain, Cardano 

June 17, 2024
Linea’s Surge Volt 2 Commences Amidst Robust Network Growth

Linea’s Surge Volt 2 Commences Amidst Robust Network Growth

June 17, 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

Related Posts

6 Best Altcoins to Buy Now June 17 – Dogwifnohat, Kendu Inu, Merlin Chain, Cardano 

6 Best Altcoins to Buy Now June 17 – Dogwifnohat, Kendu Inu, Merlin Chain, Cardano 

June 17, 2024

Join Our Telegram channel to stay up to date on breaking news coverage Today’s market dynamics reflect a blend of...

Linea’s Surge Volt 2 Commences Amidst Robust Network Growth

Linea’s Surge Volt 2 Commences Amidst Robust Network Growth

June 17, 2024

Linea has launched the second phase of its Surge initiative, Volt 2, following the successful...

Binance Expands ZKsync (ZK) Offering to Earn, Margin, and Futures

Binance Expands ZKsync (ZK) Offering to Earn, Margin, and Futures

June 17, 2024

Binance, a leading cryptocurrency exchange, has announced the addition of ZKsync (ZK) to its Simple...

Hamster Kombat Craze: Telegram Gaming Sensation Soars To 150 Million Players, Surpassing Russia’s Population

Hamster Kombat Craze: Telegram Gaming Sensation Soars To 150 Million Players, Surpassing Russia’s Population

June 17, 2024

Join Our Telegram channel to stay up to date on breaking news coverage Players of the popular Telegram-based crypto game...

Biaoqing Price Prediction: BIAO Plummets 25%, But This AI Meme Coin Rival Charges Towards $6 Million Raised

Biaoqing Price Prediction: BIAO Plummets 25%, But This AI Meme Coin Rival Charges Towards $6 Million Raised

June 17, 2024

Join Our Telegram channel to stay up to date on breaking news coverage The Biaoqing price has plummeted 25% in...

Load More

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Pixelverse Raises $5.5M for Global Expansion of Web3 Gaming

Pixelverse Raises $5.5M for Global Expansion of Web3 Gaming

June 13, 2024
Zimbabwe launches study to map and regulate crypto industry

Zimbabwe launches study to map and regulate crypto industry

June 12, 2024
Book of Meme Price Prediction: BOME Surges 9% on Coinbase Listing News, And This Solana Rival Might Be Next As Launch Nears

Book of Meme Price Prediction: BOME Surges 9% on Coinbase Listing News, And This Solana Rival Might Be Next As Launch Nears

June 14, 2024
Trezor Launches New Hardware Wallet ‘Safe 5’ with Bitcoin-only Variant

Trezor Launches New Hardware Wallet ‘Safe 5’ with Bitcoin-only Variant

June 14, 2024
BDAG’s Keynote 2 elevates presale, outshines Cardano speculation as SHIB decline

BDAG’s Keynote 2 elevates presale, outshines Cardano speculation as SHIB decline

June 14, 2024
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!

  • Creating WebVTT Files for Videos Using Node.js: A Comprehensive Guide
  • Innovate Change Reviews Innovative Features in New Crypto Casino Platforms
  • New South Korean Crypto Law To Review 600 Listed Assets
  • Shiba Inu Slated to Achieve $1 Trillion Market Cap

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.

You have not selected any currencies to display
WP Twitter Auto Publish Powered By : XYZScripts.com