npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

videogen

v1.1.3

Published

Generate Short Video With OpenAI

Downloads

224

Readme

VideoGen

VideoGen is an NPM module that transforms a textual prompt into a complete video story. It utilizes AI for generating narratives, fetches relevant video clips, generates synthesized audio, and adds subtitles, producing a final, polished video.

Features

  • AI-Powered Story Generation: Create engaging stories from user-provided prompts.
  • Keyword Extraction: Identify key phrases from the story to guide video content selection.
  • Video Retrieval: Fetch relevant video clips from Pexels.
  • Text-to-Speech: Generate audio narration using Google Text-to-Speech.
  • Subtitle Integration: Automatically generate and embed subtitles.
  • Final Video Composition: Assemble video segments, audio, and subtitles into a cohesive final product.

Installation

Install the module via npm:

npm install videogen

First create a .env file to store your API keys:

OPENAI_KEY=
OPENAI_MODEL=gpt-3.5-turbo
PEXEL_API_KEY=
GOOGLE_APPLICATION_CREDENTIALS=
OPENAI_TRANSCRIPTION_MODEL=whisper-1
OUTPUT_DIRECTORY=

Usage

const { videogen } = require("videogen");

videogen({
    prompt: 'Le football et ses risques',
    hasSubtitle: false,
    orientation: 'portrait',
    uuid: 'aa285bf5-e8f2-4e27-b6e3-138cf73f8f58',
    language: 'en-US',
    voice: 'en-US-Standard-C',
    duration: 20,
    onSuccess: async (uuid, videoPath) => {
        // DO Someting here
    },
    onFailed: async (uuid, err) => {
        // DO Someting here
    }
})

| Variable | Type | Description | |---------------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------| | prompt | string (Minimum 30 characters) | The text used to generate content. Must be at least 30 characters long to provide sufficient context. | | hasSubtitle | boolean (Default: 1) | Specifies whether subtitles should be generated and included in the video. By default, this option is enabled (true). | | orientation | string (landscape or portrait) (Default: landscape) | Defines the video's orientation. Use landscape for a horizontal video or portrait for a vertical one. The default value is landscape. | | uuid | string (Optional) | Optional unique identifier for the video. Can be used to track or specifically identify a video. | | language | string (Optional) (Default: en-US) | Language of the text and voice. Specify a language code following the BCP 47 standard. By default, en-US (English - United States) is used. | | voice | string (Optional) (Default: en-US-Standard-C) | Voice for text-to-speech narration. By default, en-US-Standard-C is used. This value may vary depending on available voices. | | duration | int (Required) | Total duration of the video in seconds. This value is required and must be specified as a whole number of seconds. | | onSuccess | async function (Required) | Asynchronous function called when the video is successfully generated. Receives the parameters uuid (unique identifier) and finalVideoPath (path to the final video file). | | onFailed | async function (Required) | Asynchronous function called if video generation fails. Receives the parameters uuid (unique identifier) and err (error encountered). |

Configuration

Pexels API Key

To fetch video content, you need a Pexels API key. You can obtain it by signing up on the Pexels API website.

Google Text-to-Speech

To generate audio, you need Google Cloud Text-to-Speech credentials. Follow the Google Cloud setup instructions to obtain your credentials.

OpenAI

To generate content, you need OpenAI API credentials. Follow the OpenAI setup instructions to obtain your credentials.

Contributing

We welcome contributions! Please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the MIT License.

Acknowledgements

  • Pexels for providing free video content.
  • Google Cloud for the Text-to-Speech API.
  • OpenAI for GPT-based story generation.

Support

For any issues or questions, please open an issue on the GitHub repository.

Enjoy creating story-based videos!