Skip to main content

Featured

Free Text-to-Speech for YouTube Videos: My Kokoro TTS Pipeline

Every tutorial and Short on my YouTube channel Omilabs is narrated by a synthetic voice. I don't record my own voiceover for these videos. The narration comes from a script that turns each line of text into audio, and that script runs on Kokoro, a small open-weight text-to-speech model. In this post I explain how I set it up, the problems I hit, and the checks I now run so the voice sounds clean and stays consistent across more than a hundred videos. Why I Picked an Open TTS Model When you make one video, a paid voice tool is easy. When you make a full series of long episodes plus many Shorts, and you rebuild the audio every time a script line changes, a few things start to matter more: Re-runs cost nothing. I edit scripts often. With a local model I can regenerate a whole episode as many times as I want. It runs anywhere. The model is small enough to run on a normal CPU, including a free GitHub Actions runner, which is where my videos are rendered now. The output is rep...

How I Automated YouTube Uploads for Free with GitHub Actions

I run a YouTube channel called Omilabs that publishes tutorials and Shorts about voice AI and AI agents. At one point I had more than a hundred finished videos waiting to go live, and uploading them by hand, writing titles and descriptions, adding thumbnails and scheduling each one, would have taken days. So I built a small system that uploads and schedules everything automatically, costs nothing to run, and does not depend on my laptop being switched on.

This post explains how it works, the mistakes I made on the way, and how you can build something similar for your own channel.

The first version failed

My first attempt was a script running on a cloud machine that I used for development. It worked well for a few days. Then the machine went to sleep when I was not using it, the upload loop stopped, and for four days nothing was published. Nobody told me; I only noticed because the channel went quiet.

That taught me the most important lesson of the whole project: an automation is only as reliable as the machine it runs on. A script on a laptop or a temporary server is not a system. It is a reminder that you have to keep something switched on.

The idea that fixed it: let YouTube do the publishing

The YouTube Data API lets you upload a video as private and give it a scheduled publish time. Once the upload is finished, YouTube itself makes the video public at that moment. No machine needs to be awake at the publish time.

That splits the problem into two separate jobs:

  1. Uploading each video some time before its slot, as private with a publish time.
  2. Publishing, which YouTube handles on its own.

Uploading can happen hours or days in advance, so it only needs to run regularly, not at an exact minute.

Where the uploads run: GitHub Actions

GitHub Actions is GitHub's automation service. A workflow file in a repository can run on a schedule, much like a cron job, on machines that GitHub provides. For my needs the free allowance was more than enough.

My workflow runs every few hours and does the following:

  1. Decrypts the YouTube credentials stored in the repository.
  2. Looks at a list of videos that are ready but not yet uploaded.
  3. Uploads the next videos in the queue as private, each with its scheduled publish time, title, description, tags, thumbnail and captions.
  4. Records what was uploaded in a small JSON file and commits it back to the repository, so the next run knows where to continue.

Because the state file is committed after every run, the repository keeps a full history of what was uploaded and when. If something goes wrong, I can see exactly which run caused it.

Keeping credentials safe

The workflow needs permission to upload to my channel. That permission comes from an OAuth token, which is effectively a key to the channel. It must never appear in code, logs or chat messages.

What I did:

  • The OAuth client file and token are stored in the repository only in encrypted form.
  • The decryption key is stored as a GitHub Actions secret, which the workflow can read but which is never printed.
  • The repository itself is private.

One more detail matters here. When a Google Cloud OAuth app is left in "testing" mode, its refresh tokens expire after a short time, and the automation silently stops. Moving the app to production in the Google Cloud console and issuing a fresh token solved that.

Where the video files live

Video files are large, and Git is not designed for them. GitHub rejects individual files over 100 MB, and Git LFS has a limited free quota. My workaround was to store each finished video on its own branch, split into parts under 50 MB. The workflow fetches only the video it is about to upload, joins the parts, uploads it, and then deletes that branch. This keeps the main repository small and fast.

It is not the most elegant solution, but it is free and it has been reliable.

The schedule

I publish long videos and Shorts at fixed times each day, spread out so they do not compete with each other. The schedule lives in the code as a simple list of time slots. When a new video is added to the queue, it takes the next free slot automatically.

YouTube also limits how many videos a channel can upload in a day. When the limit is reached, the API returns an error. My script treats that error as "stop for today" rather than as a failure, and the next run continues where it left off.

Quality checks before upload

Automation makes it very easy to publish bad videos quickly. To avoid that, each video carries a small file of quality checks, and the uploader skips anything that has not passed. The checks include whether the audio level is right, whether the render finished correctly, whether the length is in the expected range, and whether the title follows simple rules, such as keeping the main keyword near the start and staying under a length limit.

What I would do differently

  • Start with the scheduled-upload idea from day one. I wasted days on a script that needed a machine to stay awake.
  • Write state to a file early. Knowing exactly what has been uploaded prevents double uploads, which are annoying to clean up.
  • Never run two uploaders at once. When I tested a local script while the GitHub workflow was also active, both uploaded the same videos. Now there is only one uploader.
  • Log everything. A simple text log, committed after each run, made every problem easy to diagnose.

How you can build your own

  1. Create a Google Cloud project, enable the YouTube Data API v3, and create an OAuth client.
  2. Write a small script that uploads one video as private with a publishAt time. Test it manually first.
  3. Add a queue: a list of videos with their titles, descriptions and target slots.
  4. Add a state file so the script knows what has already been uploaded.
  5. Put the script in a private GitHub repository, store secrets safely, and add a scheduled workflow.
  6. Watch the first few runs closely, then let it run.

Results

The channel now publishes on a fixed daily schedule without me opening YouTube Studio for uploads. My time goes into making better videos instead of copying descriptions and picking publish times. The whole system runs on free tools, and if a run fails, the next one simply continues from the saved state.

If you have a backlog of videos and a fixed publishing rhythm, this approach is worth trying. The key is to let YouTube handle the publishing and let a scheduled, stateless job handle the uploading.

Written by Omkar Vijay Ghate, Mumbai.

Comments

Adsterra Have a blog? Monetize it with Adsterra (referral link)