Article Summarizer Agent: Summarize and Listen to Any Article with Python and Agno
Introduction
In this post, I’ll walk you through how I built an Article Summarizer Agent using Python and the Agno framework. This agent can take any article URL, generate a concise summary, and even convert that summary to audio. It’s a practical tool for anyone who wants to quickly digest web content or listen to articles on the go.
We’ll break down the implementation step by step, explain the code, and discuss how you can use and extend this agent for your own projects.
Project Overview
The goal was to create a command-line tool that:
- Accepts a URL to an online article
- Extracts the article content
- Summarizes the content (max 500 words)
- Converts the summary to audio (MP3)
- Outputs both the text and audio file
To achieve this, I used the Agno agent framework, OpenAI’s GPT-4 model, and a set of specialized tools for crawling, summarizing, and audio generation.
Code Walkthrough
1. Setting Up the Environment
First, I initialized a new Python environment and installed the required dependencies:
uv init
uv add agno openai
2. Importing Dependencies
Here’s the list of imports used in the script:
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.crawl4ai import Crawl4aiTools
from agno.tools.openai import OpenAITools
from agno.tools.reasoning import ReasoningTools
import argparse
import os
from datetime import datetime
from pathlib import Path
from agno.utils.media import save_base64_data
- The Agno framework provides the agent and tool integrations
- Standard Python libraries handle argument parsing, file management, and timestamps
3. Creating the Article Summarizer Agent
The core of the project is the agent configuration:
article_summarizer = Agent(
name="Article Summarizer Agent",
model=OpenAIChat(id="gpt-4"),
tools=[
Crawl4aiTools(),
OpenAITools(),
ReasoningTools(add_instructions=True)
],
description="You are an AI agent that summarizes articles and converts them to audio.",
instructions=[
"When given a website URL:",
"1. Use Crawl4aiTools to extract the article content",
"2. Generate a concise summary (max 500 words)",
"3. Convert the summary to audio using OpenAITools",
"4. Return both the text summary and audio"
],
markdown=True,
show_tool_calls=True
)
- The agent uses GPT-4 for language understanding
- Tools are added for crawling web content, generating audio, and reasoning
- Instructions guide the agent’s workflow step by step
4. Handling User Input and Running the Agent
The main()
function manages command-line arguments and output:
def main():
parser = argparse.ArgumentParser(description='Generate audio summary from a website article')
parser.add_argument('url', help='URL of the article to summarize')
args = parser.parse_args()
response = article_summarizer.run(f"Summarize this article and convert it to audio: {args.url}")
if hasattr(response, 'content') and response.content:
print("\nText Summary:")
print(response.content)
else:
print("\nNo text summary available.")
if hasattr(response, 'audio') and response.audio:
os.makedirs("output", exist_ok=True)
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
filename = Path(f"output/summary_{timestamp}.mp3")
save_base64_data(response.audio[0].base64_audio, filename)
print(f"\nAudio saved to: {filename}")
- The script expects a URL as a command-line argument
- It runs the agent and prints the summary if available
- If audio is returned, it saves the file in an
output
directory with a timestamped filename
5. Script Entry Point
if __name__ == "__main__":
main()
- This ensures the script runs the
main()
function when executed directly
Practical Use Cases
- Quickly summarize long articles for research or study
- Convert articles to audio for listening during commutes or workouts
- Integrate into a larger workflow for content curation or accessibility tools
Possible Extensions
- Add support for batch processing multiple URLs
- Integrate with a web interface for easier use
- Allow selection of summary length or audio format
- Add error handling for unsupported or paywalled articles
Conclusion
This Article Summarizer Agent demonstrates how you can combine modern AI tools to automate content summarization and audio generation. The Agno framework makes it straightforward to build agents that chain together multiple capabilities. With a few tweaks, you can adapt this pattern for many other automation and content processing tasks.