Summarize and analyze videos with @streamlitofficial and AssemblyAI
People & Blogs
Introduction
In this article, we will explore how to create a streamlined application that can analyze YouTube videos using links provided by users. This application combines the capabilities of Streamlit, a powerful web application framework, and AssemblyAI, an advanced audio transcription and analysis processor. By the end of this tutorial, you will have a fully functional app that can summarize video content, identify sensitive topics, and display relevant information in a user-friendly format.
Overview of the Application
The application we are building features:
- A title and explanatory text to guide users on how to use the app.
- A file upload system that accepts a list of YouTube video links in a specific format.
- The option to use a default example file for users who want to explore the app without specific links.
- A visually appealing list of video thumbnails corresponding to the uploaded links.
- When a thumbnail is selected, the app retrieves:
- The video title.
- An audio excerpt for users to listen to.
- A concise bulleted summary of the video’s content.
- Indicators of any sensitive content detected.
- A list of topics discussed in the video.
This project is a collaboration between Streamlit and AssemblyAI, and will guide users in auditing YouTube channels effectively.
Setting Up the App
To start, we will import the necessary libraries. The centerpiece of our project is Streamlit (imported as st
), coupled with PyTube for downloading audio and Pandas for managing data frames.
Creating the User Interface
- Title and Explanation: The app will present a title and a brief explanation of its capabilities.
- File Upload Functionality: Users can upload a text file containing links or opt for a default example file for demonstration.
- Video Thumbnails Display: Once the file is uploaded, the app will display the corresponding thumbnails.
Audio Downloading Functionality
We will create a function, save_audio
, using PyTube, which allows us to download audio files from YouTube. This function leverages the video’s URL to retrieve its details, such as the title and thumbnail, after ensuring the audio is saved in the MP3 format.
Analysis of Selected Videos
When a user selects a video thumbnail, the application will:
- Extract the video URL, title, and audio location.
- Display the audio clip for listening.
We will integrate AssemblyAI to upload the audio for the following analysis:
- Upload Audio to AssemblyAI: Using our
upload_to_assembly_ai
function, we will send the audio file to AssemblyAI’s servers. - Start Analysis: The app will initiate the analysis process using another function called
start_analysis
, which configures the desired models for transcription, topic detection, and content moderation. - Polling for Results: We’ll implement a polling mechanism with our
get_analysis_results
function to wait until AssemblyAI completes the analysis and retrieves the results.
Displaying the Results
After the analysis is complete, the app will display:
- A summary of the audio.
- Any detected sensitive content and the corresponding details.
- A comprehensive list of topics discussed within the video organized in a data frame format.
Conclusion
This application efficiently combines various technologies to provide comprehensive video analysis and content summary based on user input. Streamlit and AssemblyAI together create a powerful tool for YouTube content analysis, allowing users to engage deeply with video material.
Keywords
- Streamlit
- AssemblyAI
- YouTube video analysis
- Audio transcription
- Sensitive content detection
- Video summarization
- Data visualization
- Application development
FAQ
Q: What is the purpose of the application?
A: The application is designed to analyze YouTube videos by summarizing their content, identifying sensitive topics, and displaying relevant information in a user-friendly manner.
Q: Do I need to create an account to use AssemblyAI?
A: Yes, you will need to sign up for an account on AssemblyAI to obtain an API key for authentication.
Q: Can I use a file with any format to upload links?
A: No, the app only accepts text files with YouTube links formatted as youtube.com
(not youtube.be
).
Q: Is there a demo version of the application?
A: Yes, the application provides a default example file for users who want to test the functionality without specific links.
Q: How is the analysis performed?
A: The app uploads the audio to AssemblyAI, initiates analysis via their API, and retrieves results that include summaries, topic detection, and content moderation feedback.