Skip to content

Commit

Permalink
Add support for getting API key from environment
Browse files Browse the repository at this point in the history
  • Loading branch information
alamshafil committed Sep 25, 2024
1 parent a8e7a75 commit 914f806
Show file tree
Hide file tree
Showing 7 changed files with 810 additions and 39 deletions.
66 changes: 53 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ If you want to support the development of this package, consider buying me a cof

[![ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=for-the-badge&logo=ko-fi&logoColor=white)](https://ko-fi.com/shafilalam)

Your support will help me to continue the development of this package. Thank you!

> [!WARNING]
> The package author is not responsible for any misuse of the package, any content generated by the package, and any loss arising from the use of the package. Use at your own risk. Package is subject to change and may have breaking changes in the future. Not meant for production usage.
Expand Down Expand Up @@ -47,12 +49,20 @@ Note: By default, the package use Ollama to generate scripts. Therefore a workin

## For JS Interface
```bash
# Install the package
npm install auto-shorts

# Download the necessary resources (to './res' folder by default)
npx auto-shorts --download
```

## For CLI Interface (global installation)
```bash
# Install the package globally
npm install -g auto-shorts

# Download the necessary resources (to './res' folder by default)
npx auto-shorts --download
```

# Example (CLI Interface)
Expand All @@ -67,7 +77,13 @@ npm install -g auto-shorts
npx auto-shorts --download

# Generate a video with AI (will find the necessary resources in the './res' folder)
npx auto-shorts -p "make a news short about TypeScript" --ttsType ElevenLabsVoice --imageType PexelsImageGen --elevenLabsAPIKey YOUR_ELEVENLABS_API_KEY --pexelsAPIKey YOUR_PEXELS_API_KEY
# You have options to use different AI tools to generate the script, voice, and image

# Use OpenAI gpt-4o-mini to generate the script, ElevenLabs to generate the voice, and Pexels to generate the image
npx auto-shorts -p "make a news short about TypeScript" --aiType OpenAIGen --ttsType ElevenLabs --imageType PexelsImageGen --elevenLabsAPIKey YOUR_ELEVENLABS_API_KEY --pexelsAPIKey YOUR_PEXELS_API_KEY --openaiAPIKey YOUR_OPENAI_API_KEY

# Use local Ollama llama3.1 to generate the script, Built-in TTS to generate the voice, and Google Scraper to generate the image (default, no need to provide API keys)
npx auto-shorts -p "make a news short about TypeScript"
```

You can also run the command interactively and provide the necessary information when prompted:
Expand All @@ -90,15 +106,20 @@ npx auto-shorts --download [path]
## AI-Generated Video
```javascript
const task = await genVideoWithAI(
"make a news short about TypeScript",
AIGenType.OllamaAIGen, {
tempPath: 'video_temp',
resPath: 'res',
voiceGenType: VoiceGenType.ElevenLabsVoice,
imageGenType: ImageGenType.PexelsImageGen,
elevenLabsAPIKey: process.env.ELEVENLABS_API_KEY,
pexelsAPIKey: process.env.PEXELS_API_KEY,
});
"make a news short about TypeScript", // Provide the prompt
AIGenType.OpenAIGen, // Use OpenAI to generate the script
{
tempPath: 'video_temp', // Provide the path to the temporary video folder
resPath: 'res', // Provide the path to the downloaded resources folder
voiceGenType: VoiceGenType.ElevenLabsVoice, // Use ElevenLabs to generate the voice
imageGenType: ImageGenType.PexelsImageGen, // Use Pexels to generate the image
apiKeys: {
elevenLabsAPIKey: process.env.ELEVENLABS_API_KEY, // Provide the ElevenLabs API key
pexelsAPIKey: process.env.PEXELS_API_KEY, // Provide the Pexels API key
}
},
process.env.OPENAI_API_KEY // Provide the OpenAI API key
);

task.on('log', (log) => {
console.info(log);
Expand Down Expand Up @@ -128,8 +149,10 @@ const task = await genVideoWithJson(
resPath: 'res',
voiceGenType: VoiceGenType.ElevenLabsVoice,
imageGenType: ImageGenType.GoogleScraperImageGen,
elevenLabsAPIKey: process.env.ELEVENLABS_API_KEY,
pexelsAPIKey: process.env.PEXELS_API_KEY,
apiKeys: {
elevenLabsAPIKey: process.env.ELEVENLABS_API_KEY,
pexelsAPIKey: process.env.PEXELS_API_KEY,
}
});

task.on('log', (log) => {
Expand All @@ -149,15 +172,28 @@ You need to provide the following API key depending on what tools you want to us
- ElevenLabs API Key
- Pexels API Key
- Neets.ai API Key
- OpenAI API Key *(coming soon)*
- OpenAI API Key

Make sure to provide the API keys in the environment variables with a package like `dotenv`.

# Contributing

If this package is missing any video types or AI tools that you would like to see, feel free to create an issue on the GitHub repo. You can also contribute to the package by creating a pull request to add new video types or AI tools.

# Layout

The package is structured as follows:
- `src`: Contains the source code for the package
- `example`: Contains example code to use the package
- `test`: Contains test code for the package
- `packages`: Contains the internal dependencies for the package (forked versions of `ffcreator` and `inkpaint`)

# Todo
- [ ] Add GUI
- [ ] Fix logging
- [ ] Make AI output structured for local LLMs (gpt4, gemini, claude are fine)
- [ ] Add more video types (Twitter/X posts, Reddit posts, etc.)
- [ ] Add Docker support
- [ ] Add more AI tools (e.g., OpenAI, Neets.ai, AI Image Generators, etc.)
- [ ] Add more customization options (custom fonts, colors, images, etc.)
- [ ] Add more error handling
Expand All @@ -166,4 +202,8 @@ Make sure to provide the API keys in the environment variables with a package li
- [ ] Add support for more general video generation (e.g., long-form videos)
- [ ] Fix external dependencies vulnerabilities (only on dev dependencies)

## Star History

[![Star History Chart](https://api.star-history.com/svg?repos=alamshafil/auto-shorts&type=Date)](https://star-history.com/#alamshafil/auto-shorts&Date)

**By Shafil Alam.**
24 changes: 15 additions & 9 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,21 @@ const data = {
images: ["typescript logo"]
};

const task = await genVideoWithJson(
data, {
tempPath: 'video_temp',
resPath: 'res',
voiceGenType: VoiceGenType.ElevenLabsVoice,
imageGenType: ImageGenType.GoogleScraperImageGen,
elevenLabsAPIKey: process.env.ELEVENLABS_API_KEY,
pexelsAPIKey: process.env.PEXELS_API_KEY,
});
const task = await genVideoWithAI(
"make a news short about TypeScript", // Provide the prompt
AIGenType.OpenAIGen, // Use OpenAI to generate the script
{
tempPath: 'video_temp', // Provide the path to the temporary video folder
resPath: 'res', // Provide the path to the downloaded resources folder
voiceGenType: VoiceGenType.ElevenLabsVoice, // Use ElevenLabs to generate the voice
imageGenType: ImageGenType.PexelsImageGen, // Use Pexels to generate the image
apiKeys: {
elevenLabsAPIKey: process.env.ELEVENLABS_API_KEY, // Provide the ElevenLabs API key
pexelsAPIKey: process.env.PEXELS_API_KEY, // Provide the Pexels API key
}
},
process.env.OPENAI_API_KEY // Provide the OpenAI API key
);

task.on('log', (log) => {
console.log(log);
Expand Down
Loading

0 comments on commit 914f806

Please sign in to comment.