Summarize and analyze videos with @streamlitofficial and AssemblyAI

AssemblyAIAssemblyAI
People & Blogs4 min read39 min video
Nov 4, 2022|3,754 views|113|10
Save to Pod

Key Moments

TL;DR

Build a Streamlit app with AssemblyAI to analyze YouTube video content: summarize, detect sensitive topics, and list discussions.

Key Insights

1

Streamlit enables interactive web app development for data analysis.

2

AssemblyAI provides powerful APIs for audio/video content analysis (summarization, topic detection, content safety).

3

The app allows users to upload video links via TXT file or use a default example.

4

Custom Streamlit components (e.g., clickable images) enhance user interaction.

5

Caching mechanisms (`st.cache_resource`) are crucial for performance by preventing redundant computations.

6

The analysis extracts video titles, audio, summaries, sensitive content flags, and detailed topic breakdowns.

INTRODUCTION TO THE YOUTUBE CONTENT ANALYZER APP

This project introduces a Streamlit application designed to analyze YouTube videos. Users can input a list of YouTube video links via a TXT file, select a video from displayed thumbnails, and receive an analysis including a summary, detection of sensitive content, and a list of discussed topics. The app serves as a collaborative effort between Streamlit and AssemblyAI, with a comprehensive written tutorial available on the Streamlit blog.

CORE FUNCTIONALITY AND FRONTEND SETUP

The Streamlit app begins with a title and explanatory text. It incorporates a file uploader for users to submit TXT files containing video links and a checkbox for using a default example file. The selected file containing links is then processed into a Python list, ready for further operations. The user interface is designed to be intuitive, guiding users through the process of uploading links and selecting videos for analysis.

AUDIO EXTRACTION AND THUMBNAIL DISPLAY

To facilitate analysis, the application first downloads the audio from each YouTube video using the `pytube` library. During this process, it extracts essential video information such as the title, thumbnail URL, and the save location of the audio file. For user selection, a custom Streamlit component called 'clickable images' is employed to display video thumbnails in a grid, allowing users to easily choose a video of interest.

INTEGRATION WITH ASSEMBLYAI FOR CONTENT ANALYSIS

Once a video is selected, its audio file is uploaded to AssemblyAI. This initiates a multi-step analysis process. First, the audio is uploaded to AssemblyAI, which returns an upload URL. Subsequently, a transcription job is started, configuring AssemblyAI to perform summarization, topic detection (IAb categories), and content safety analysis. The audio URL is then passed to the analysis function.

POLLING FOR ANALYSIS COMPLETION AND RESULT RETRIEVAL

Since AssemblyAI's analysis is asynchronous, the application polls an endpoint using a unique job ID to check for completion. It enters a loop, periodically requesting the status of the analysis. Once the job is marked as 'completed', the application retrieves the results. If the analysis encounters an error, the process stops. This polling mechanism ensures that results are fetched only after the analysis is fully processed.

DISPLAYING ANALYSIS RESULTS

The retrieved analysis results are then presented to the user. This includes a concise summary of the video, a breakdown of any detected sensitive topics (listing the topic, confidence, and severity), and a categorized list of all discussed topics and subtopics. The results are displayed in a user-friendly format, often using Streamlit's data frame components for organized presentation and readability.

PERFORMANCE OPTIMIZATION WITH CACHING

To enhance performance and prevent redundant computations, the application leverages Streamlit's caching capabilities. Specifically, the `st.cache_resource` decorator is used for functions like audio saving and AssemblyAI analysis. This ensures that if the same inputs are provided again, the results are served from the cache, significantly speeding up the app's response time, especially when dealing with multiple videos or repeated analyses.

HANDLING USER INPUT AND FILE FORMATS

The app provides clear instructions on the expected format for the input TXT file, specifying that links should be in the `youtube.com` format and not `youtube.be`, as the latter might not be compatible with the libraries used. This attention to detail in user input validation ensures a smoother user experience and reduces potential errors during file processing.

ADVANCED DISPLAY OF TOPICS AND SAFETY FEATURES

The presentation of topics is refined by separating main topics from subtopics and displaying them in distinct columns within a Streamlit data frame, along with their confidence scores. For sensitive content, the app checks for the presence of detected items and informs the user accordingly, presenting a summary of detected sensitive topics, their confidence levels, and severity, or confirming their absence.

CONCLUSION AND FUTURE IMPROVEMENTS

The completed application successfully integrates Streamlit's frontend capabilities with AssemblyAI's powerful backend analysis services. The project demonstrates a practical approach to analyzing video content for various insights. The developers encourage user feedback and suggest potential future enhancements, highlighting the dynamic nature of web application development and the value of community contributions.

YouTube Video Analysis App Quick Guide

Practical takeaways from this episode

Do This

Ensure YouTube links are in the standard format (youtube.com/...).
Upload links as a .txt file.
Select a video thumbnail to initiate analysis.
Use the audio widget to listen to the selected video's audio.
Check for summary, sensitive topics, and discussed topics after analysis.

Avoid This

Do not use shortened YouTube links (youtube.be/...) as they may not work with the libraries.
Do not expect instant analysis; there's a polling process.
Do not provide links in formats other than what's specified.

Common Questions

You can use a web application built with Streamlit and AssemblyAI. This app allows you to upload a list of YouTube video links, download their audio, and then analyze the content for summaries, topics, and sensitive content.

Topics

Mentioned in this video

More from AssemblyAI

View all 48 summaries

Found this useful? Build your knowledge library

Get AI-powered summaries of any YouTube video, podcast, or article in seconds. Save them to your personal pods and access them anytime.

Try Summify free