Giter Site home page Giter Site logo

shortrocity's Introduction

Shortrocity

Shortrocity is a tool for making AI generated short videos ("shorts" or "reels") with a ChatGPT generated script, narrated by ElevenLabs or OpenAI text-to-speech. DALL-E 3 generated background images are also added to the background. Captions with word highlighting are generated with Captacity, which uses OpenAI Whisper.

Quick Start

First, add your API-keys to the environment:

$ export OPENAI_API_KEY=YOUR_OPENAI_API_KEY
$ export ELEVEN_API_KEY=YOUR_ELEVENLABS_API_KEY

Then, put your source content in a file, for example source.txt and run the main.py:

$ ./main.py source.txt
Generating script...
Generating narration...
Generating images...
Generating video...
DONE! Here's your video: shorts/1701788183/short.avi

Caption styling

Optionally, you can specify a settings file to define settings for the caption styling:

$ ./main.py source.txt settings.json

The settings file can look like this, for example:

{
    "font": "Bangers-Regular.ttf",
    "font_size": 130,
    "font_color": "yellow",

    "stroke_width": 3,
    "stroke_color": "black",

    "highlight_current_word": true,
    "word_highlight_color": "red",

    "line_count": 2,

    "padding": 50,

    "shadow_strength": 1.0,
    "shadow_blur": 0.1
}

shortrocity's People

Contributors

unconv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shortrocity's Issues

FileNotFoundError on Windows 11

@unconv Getting the following error, can anyone help?

C:\CodeRelated\shortrocity> python .\main.py .\source.txt
C:\Users\you\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
Generating script...
Generating narration...
Generating images...
Generating video...

C:\Users\you\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\utils.py:198: RuntimeWarning: Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work
  warn("Couldn't find ffprobe or avprobe - defaulting to ffprobe, but may not work", RuntimeWarning)
Traceback (most recent call last):
  File "C:\CodeRelated\shortrocity\main.py", line 91, in <module>
    video.create(narrations, basedir, output_file)
  File "C:\CodeRelated\shortrocity\video.py", line 56, in create
    duration = get_audio_duration(narration)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\CodeRelated\shortrocity\video.py", line 10, in get_audio_duration
    return len(AudioSegment.from_file(audio_file))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\you\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\audio_segment.py", line 728, in from_file
    info = mediainfo_json(orig_file, read_ahead_limit=read_ahead_limit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\you\AppData\Local\Programs\Python\Python312\Lib\site-packages\pydub\utils.py", line 274, in mediainfo_json
    res = Popen(command, stdin=stdin_parameter, stdout=PIPE, stderr=PIPE)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\you\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\you\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 1538, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified

Also I had to modify line 19 on main.py to:
with open(sys.argv[1], errors='ignore') as f:
So that it reached the place it reached now.

It's a very cool project!

The project you've done is really cool!
I really like the project you've done!

Just a thought, maybe adding some background music would make it even better :)

cannot import name generate from elevenlabs

./main.py content_1.txt Traceback (most recent call last): File "/home/pannet1/Programs/py/youtube/shortrocity/./main.py", line 9, in <module> import narration File "/home/pannet1/Programs/py/youtube/shortrocity/narration.py", line 1, in <module> from elevenlabs import generate, set_api_key, save, RateLimitError ImportError: cannot import name 'generate' from 'elevenlabs'

has elevenlabs api changed

Possibilty of just using OPENAI?

Is there a way to just use openai instead of elevenlabs for the narration.py?
I am fairly new to this kind of thing and just wondering

Suggestions for future versions

7 questions/suggestions:

  • There can be a method at various stages to pseudo exit and first check the script generated (so as to edit it if required), then pseudo exit at the images generated so that they can be replaced if they look lame, at this stage images and video can be put in the folder for the next stage, and then the script can continue onto the final video.
  • what if we want to try out using already available videos of finite number (aspect ratio and landscape/portrait can be different from the desired final one) or available images (aspect ratio and landscape/portrait can be different from the desired final one) of finite number. The number of videos may be less or greater than the number of narration verses?
  • Like there should be some way to match the number of already available images or videos and put the available narrations on them to match the length of the end video.
    Have you given that a thought? A suggestion to make it even better.
  • Probably if the above 2 are not possible, some form of tool using OpenCV or an AI tool can be used to animate the images generated and the animation can be used in the video.
  • An option can be integrated to use LeonardoAI instead of Dalle.
  • As input parameter to the script photoreal, anime and other models can be given when Leonardo AI is used.
  • Probably there can be a method to add in background music from a file at 15% volume or so.

API-keys

hi im really new with coding and i can't seem to find out where i need to put the API-keys

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.