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!