Get Your weekly dose of insights

Join my newsletter, “3 Things I Learned Last Week”
for your weekly dose of insights.

Stay up-to-date with the latest trends, discoveries, and ideas that can help you grow both personally and professionally, as I share the top three things I learned from my explorations across a variety of media.

Subscribe now and join the journey of continuous learning and discovery.

How to summarize YouTube video for free using Gemini API

We’ve all been there…

A fascinating YouTube video promises to reveal the secrets of the universe, teach us a new skill, or simply entertain us. But then reality sets in. The video is hours long. You scroll endlessly, trying to find the key takeaways, but your attention drifts.

Before you know it, you’ve lost valuable time without gaining much knowledge.

“Started watching for knowledge, ended up in dreamland.”

But…

What if you could cut through the clutter and get the gist of any YouTube video in minutes, even seconds? What if you could turn those hours of content into concise, digestible summaries?

That’s where Gemini API comes in.

This cutting-edge AI, particularly its 1.5 Pro version, is a game-changer for anyone who wants to learn efficiently and reclaim their time. It can analyze and condense even the longest videos into summaries that capture the most important points.

And the best part?

We’re going to show you how to do it for free.

via GIPHY

Building on the concepts we explored in my previous guide on summarizing long-form content, we’ll walk you through the steps to create your own free YouTube summarization tool. No coding expertise needed, just a few simple tools and a willingness to learn.

Why should you use this method?

  • Free: Take advantage of Gemini’s generous free tier.
  • Easy: The setup is surprisingly straightforward, even if you’re not tech-savvy.
  • Customizable: Tailor the summarization process to your specific needs and preferences.

Ready to transform your YouTube experience? Let’s dive in!

.

.

.

Essential Tools and Setup


Before we dive into creating your YouTube summarization workflow, let’s gather the necessary tools and set up your accounts.

1. Gemini API Key

Think of an API key as a digital passport that grants your applications access to Gemini’s powerful capabilities.

To get your free Gemini API key:

1. Visit the Google AI Studio website and sign up for a free account: https://ai.google.dev/aistudio

2. After signing up for a new account, click on the “Get API Key” button at the top of the left panel to navigate to the API Keys section.

3. Next, click on the “Create API Key” button:

4. Next, click on “Create API key in new project”. Alternatively, if you are already familiar with the Google Cloud platform, you can select an existing project.

5. Once the API key is generated, click the “Copy” button to copy the API key to your clipboard. Ensure you store the API key in a safe place as it will be needed later when integrating it into Pipedream.

Understanding the Free Tier of Gemini API:

Gemini’s free tier is incredibly generous, allowing you to process a significant number of videos without incurring any costs.

However, it’s important to be aware of the usage limits:

  • 50 requests per day: This means you can summarize up to 50 YouTube videos within a 24-hour period.
  • 32,000 tokens per minute: Each request to Gemini is measured in tokens, which roughly correspond to 4 characters of text per token. So, for example, a 1,000-character transcript would use up approximately 250 tokens.

Note: These usage limits apply specifically to Gemini 1.5 Pro, the version we’ll be using in this guide.

Keep these limits in mind as you use the tool to avoid hitting any restrictions. We’ll discuss strategies for maximizing your free usage later in this guide.

2. Pipedream

Pipedream is our automation powerhouse.

It acts as the bridge between Slack, Gemini API, and the custom code that fetches and processes YouTube transcripts. Here’s why we love Pipedream for this task:

  • Generous Free Tier: Pipedream offers a free plan with enough resources to handle your YouTube summarization needs.
  • Custom Code: Pipedream’s flexibility allows you to add your own code snippets, opening up a world of possibilities for customizing your workflow.

To get started, sign up for a free Pipedream account: https://pipedream.com/auth/signup

3. Slack

Slack serves as the convenient interface for your YouTube summarizer.

You’ll simply paste a YouTube video link into a designated Slack channel, and Pipedream will take care of the rest, delivering the summary right back to you in the same channel.

If you don’t already have a Slack workspace, creating one is quick and easy: https://slack.com/get-started

Once you’re in Slack, create a new channel specifically for your YouTube summaries.

This will keep things organized and make it easy to track your requests.

Now that you have all the tools ready, let’s move on to building your workflow!

.

.

.

Building Your Automation Magic


Now that you have your tools ready, let’s create the automation magic that will summarize your YouTube videos.

Step 1: Integrating Your Tools

1. Add Gemini API Key into Pipedream:

Navigate to the “Accounts” page on your Pipedream dashboard and click the “Connect an App” button in the top right corner.

A popup will appear. You’ll then need to search for “Gemini” and select the “Google Gemini” option.

Next, take the Gemini API key you copied from Google AI Studio earlier and paste it into the “API Key” field.

Click the “Save” button to store your changes.

2. Connect Slack with Pipedream:

Return to the “Accounts” page and click the “Connect an App” button in the top right corner. Then, search for “Slack” and select it.

Follow the on-screen instructions to authorize Pipedream to access your Slack workspace.

3. Create New Pipedream Project and Workflow:

Go to the “Projects” page and click on the “Create Project” button.

Enter your project name and click on the “Create Project” button.

To create a new workflow, click on the “New > Workflow” button.

Provide a descriptive name for your workflow, like “YouTube Summarizer”, set the timeout to 120s, and memory to 512MB.

Then click on “Create Workflow” to finalize the process.

Step 2: Building the Workflow Logic

Now, let’s design the step-by-step process Pipedream will follow to summarize your videos:

1. Add a Slack trigger into the workflow

This trigger enables Pipedream to initiate the workflow whenever a new message is posted in your designated Slack channel.

Start by clicking the “Add Trigger” button.

Search for “Slack” and select the “Slack” option.

Next, choose the “New Message in Channels (Instant)” option.

Select your Slack account, the Slack channel you previously created, and set Ignore bots to “TRUE”.

Click the “Save and continue” button to proceed.

After that, send a test message in Slack that contains only one YouTube video link.

Once it’s posted, you should see a new event on your Pipedream workflow.

Choose the new event to see all related thread data.

You should see the YouTube link you entered listed under the text key.

2. Fetch the YouTube video transcript using a custom code block:

Next, we’ll insert a custom code block. This will enable us to fetch the transcript of the YouTube video from the link we send via a Slack message.

To do that, we’ll add a new block into our workflow by clicking the “+” button here:

And then, select the “Run Custom Code” option.

A “Custom Code” block will be added into your workflow. Rename it as “fetch_transcript”, insert the following code into the editor, and use the “Test” button to try out the block.

import { getSubtitles } from 'youtube-captions-scraper';

export default defineComponent({
  async run({ steps, $ }) {
    // get youtube url from slack trigger
    let youtube_url = steps.trigger.event.text;
    // remove < and > from url
    youtube_url = youtube_url.replace(/[<>]/g, '');
    // extract video id from url
    let video_id = '';
    if (youtube_url.includes('watch?v=')) {
      video_id = youtube_url.split('watch?v=')[1].split('&')[0];
    } else if (youtube_url.includes('youtu.be/')) {
      video_id = youtube_url.split('youtu.be/')[1].split('?')[0];
    } else {
      throw new Error('Invalid youtube url');
    }
    
    // get video transcript
    const transcript = await getSubtitles({
      videoID: video_id, // youtube video id
      lang: 'en' // default: `en`
    });
    // join all the text in the transcript
    return transcript.map( (item) => item.text ).join(' ');
  },
})

After completing the testing, you should see the video’s transcript in the result.

3. Send Transcript to Gemini API

After extracting the transcript from the YouTube video, it’s time to submit it to Gemini 1.5 Pro for a summary request.

To begin, add a new block by clicking the “+” button.

Search for “Gemini” and select the “Google Gemini” option.

Next, choose the “Generate content from text” option.

Finally, rename it to “get_summary”. Select your Google Gemini account, choose the “Gemini 1.5 pro” model, and paste the following summary prompt into the “prompt text” box.

{{steps.fetch_transcript.$return_value}}

I want you to summarize the content above using the instructions below:
---
### Instructions for Crafting a Detailed Summary:
1. **Objective**:
   Understand that the purpose of this summary is to extract the essential insights, strategies, examples, tactics, and tips from the content. The reader should gain key knowledge from your summary without having to read the entire content line by line.

2. **Length**:
   While brevity is valued, it should not come at the expense of key information. It's better to have a longer, comprehensive summary than a brief one that misses out on crucial insights.

3. **Detailing Topics**:
   - When summarizing a section, delve beyond just the headline. Dive into the sub-points and nuances.
   - If specific examples are provided to illustrate a point, include those examples.
   - If a particular strategy or tactic is mentioned, describe it briefly in your summary.

4. **Incorporate Direct Quotes**:
   If there's a particularly impactful or insightful quote from the content, include it verbatim, ensuring you attribute it to the speaker or author.

5. **Use Bullet Points for Clarity**:
   - Bullet points make content easier to scan and digest.
   - For instance, if multiple strategies are discussed under a section, list each strategy as a separate bullet point with a brief description or example.

6. **Avoid Generalizations**:
   Avoid phrases like "Various strategies are discussed." Instead, specify what those strategies are: "The content discusses strategies such as A, B, and C, explaining that..."

7. **Conclude with Takeaways**:
   At the end of your summary, include a "Key Takeaways" section. This should be a bullet-pointed list that captures the core lessons, strategies, and insights from the content.

---

Note: The summary prompt is identical to the one shared in the previous article on How to Use AI to Quickly Digest Long-Form Content Like a Pro.

Now that everything is prepared, you can click the “Test” button to generate the summary. After the process completes, the summary will appear in the “Results” section.

5. Post Summary to Slack:

For the final step, we’ll send the generated summary back to the Slack channel as a reply to the original message containing the YouTube link.

Click the “+” button to add a new block.

Search for “Slack” and select it.

Next, choose the “Reply to a Message Thread” option.

Select your Slack account and channel.

Under the “Text” option, find the result of “get_summary”, locate the path to the generated summary by Gemini 1.5 pro, and click the “Select Path” option.

Under the “Message Timestamp” option, find the result of “trigger”, locate the ts key under the event, and click the “Select Path” option.

Click the “Test” button to trigger the reply.

A reply should now be added to your original Slack message.

5. Deploy your workflow

That’s it! Now, all you need to do is deploy the workflow.

The next time you paste a YouTube video link to the Slack channel, you should receive the summary within a minute or two.

To get started quickly, clone this Pipedream Workflow by visiting this link: https://go.nathanonn.com/yt-summarizer

Congratulations! You’ve successfully built your very own YouTube video summarizer. Now you can quickly get the gist of any video without having to watch the entire thing.

.

.

.

Strategies to Overcoming Gemini API Limitations and Maximize Your Free Usage


As we mentioned earlier, Gemini 1.5 Pro’s free tier is incredibly generous, offering:

  • 50 requests per day: This means you can summarize up to 50 YouTube videos within a 24-hour period.
  • 32,000 tokens per minute: Each request to Gemini 1.5 Pro consumes tokens, and the free tier limits you to 32,000 tokens per minute.

While these limits are sufficient for most users, you might run into them if you’re summarizing a large number of videos.

Let’s explore these limits and discover some clever strategies to get the most out of your free YouTube summarization tool.

Strategy 1: Strategic Scheduling

Don’t try to summarize all your videos at once.

Spread out your requests throughout the day to stay within the daily limit. Here’s how you can achieve this using Slack’s message scheduling feature:

1. Compose your message in the Slack channel dedicated to your YouTube summaries. Paste the YouTube video link you want to be summarized.

2. Click on the “Down Arrow” button next to the Send button. This will reveal a menu with various options.

3. Select “Custom Time” from the menu.

4. Choose a date and time in the future when you want the message containing the YouTube link to be automatically sent to the channel. You can pick a specific time slot within the day or even schedule it for a different day altogether.

By scheduling your messages throughout the day, you’ll ensure your requests are spread out evenly and avoid exceeding the daily limit. This allows you to summarize a larger number of videos without having to worry about hitting a wall.

Strategy 2: Prioritize Important Videos

Not all videos are created equal.

Focus on summarizing the videos that are most crucial to you first. This ensures you get summaries for the content that matters most, even if you reach your daily limit. For less critical videos, consider alternative summarization methods like skimming through the video yourself or searching for online summaries.

Alternatively, you can wait until the next day to use your daily quota on Gemini for these videos.

Strategy 3: Switching to Gemini 1.5 Flash

If you need to summarize a large number of shorter videos, Gemini 1.5 Flash might be a better option for you, offering higher limits:

  • 1,500 requests per day
  • 15 requests per minute
  • 1 million tokens per minute.

This makes it ideal for situations where you need to quickly summarize a large batch of videos, even if they’re on the shorter side.

Here’s how to switch to Gemini 1.5 Flash in Pipedream:

1. Navigate to your Pipedream workflow for YouTube summarization.

2. Locate the block where you select the Gemini API model. From the dropdown menu for selecting the API model, choose “Gemini 1.5 Flash” instead of “Gemini 1.5 Pro”.

3. Save your changes and redeploy the workflow.

Important to remember: The quality of the summaries generated by Gemini 1.5 Flash might not be as comprehensive as those created by 1.5 Pro. So, if in-depth summaries are crucial for your needs, stick with 1.5 Pro and employ the scheduling or prioritization strategies.

The key is to try out these strategies and see what delivers the best results for your specific use case.

For instance, you might discover that strategic scheduling with Gemini 1.5 Pro perfectly suits your needs. On the other hand, you might find that a combination of scheduling with Gemini 1.5 Pro and using Gemini 1.5 Flash for shorter videos is the most optimal solution.

Experiment with these strategies to find the optimal balance that maximizes your free usage and helps you get the most from your YouTube summarization tool.

.

.

.

Conclusion


Congratulations!

You’ve successfully harnessed the power of Gemini API, Pipedream, and Slack to build your own free YouTube video summarization tool.

Key Takeaways

Let’s recap the key advantages of this method:

  • Cost-Effective: Leverage the free tiers of Gemini API and Pipedream to get powerful summarization capabilities without spending a dime.
  • Time-Saving: Quickly extract the most important information from YouTube videos, freeing up your valuable time for other tasks.
  • Customizable: Tailor the summarization process to your preferences by tweaking the workflow or experimenting with different prompts.
  • Easy to Use: Even if you’re not a tech expert, you can set up this workflow with minimal effort.
  • Accurate and Relevant: Gemini 1.5 Pro’s advanced language processing ensures that the summaries are accurate and capture the essence of the video’s content.

Next Steps: Take Action!

Now that you have this powerful tool at your disposal, here’s what you can do:

  • Start Summarizing: Dive into your favorite YouTube channels and put your new summarization bot to work.
  • Share Your Experience: Tell your friends, colleagues, or fellow learners about this handy tool.
  • Explore Further:
    • Experiment with different prompts to fine-tune the summaries.
    • Consider upgrading to a paid Gemini plan for even more features and capabilities.
    • Explore other ways to customize your Pipedream workflow.

I hope this guide has empowered you to take control of your YouTube video consumption and extract valuable insights more efficiently.

Happy summarizing!

The author partially generated this content with GPT-4 & ChatGPT, Claude 3, Gemini Advanced, and other large-scale language-generation models. Upon developing the draft, the author reviewed, edited, and revised the content to their liking and took ultimate responsibility for the content of this publication.


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *