Build a Transcription Web App with Streamlit | Part 1
Table of Contents:
- Introduction
- Project Structure
- Installing Dependencies
- Creating the Base Streamlit Application
- Setting Up YouTube Downloader
- Setting Up ffmpeg Library
- Setting Up Assembly AI API
- Transcribing YouTube Videos
- Checking Transcription Status
- Conclusion
Introduction
In this tutorial, we will be building a web app using Streamlit and Assembly AI that has the power to transcribe YouTube videos just from their link. This will be a two-part tutorial, where in this video, we will write the code that transcribes a YouTube video, and in the next video, we will go into the details of a Streamlit application and make it more user-friendly. The final app will allow users to input a YouTube link, display the video in a player, and Show the transcription below the video. We will be using Assembly AI's API to achieve this, and you can sign up for a free account to follow along.
Project Structure
To start the project, Create a project folder on your desktop called "YouTube Transcriber". Inside this folder, create two files: the main web application file (python file) and the configuration file. The configuration file will contain your Assembly AI authentication key. Install the necessary dependencies, including Streamlit and YouTube DL, using pip. Additionally, install the ffmpeg library, which is trickier to install and may differ Based on your operating system.
Installing Dependencies
To install Streamlit, use the command "pip install streamlit". Next, install the YouTube DL library using the same command. If you haven't already, download and install the ffmpeg library based on your operating system. Specify the path of the ffmpeg executable in the configuration file for Windows users.
Creating the Base Streamlit Application
Start by creating the title of the application: "An Easy Way to Transcribe YouTube Videos." Add a text input for users to input the YouTube link. At this point, the application will not perform any actions.
Setting Up YouTube Downloader
Create a function that uses the YouTube DL library to download the YouTube video as an audio file, saved with the specified naming format. Strip any blank spaces from the link before passing it to the library. Display the progress of the download in the application. Run the application to test the downloading functionality.
Setting Up ffmpeg Library
Set up options and constants for using the ffmpeg library. Specify the location of the ffmpeg executables based on your system. This step is essential for turning the downloaded video into an audio file. Set up the Assembly AI API by providing the upload and transcript endpoints. Add the authentication header using the Assembly AI authentication key from the configuration file.
Transcribing YouTube Videos
Create a function that handles the transcription process. Download the video, upload it to Assembly AI using the upload endpoint, and initiate the transcription using the transcript endpoint. Return the polling endpoint to check the transcription status. When calling this function, pass the YouTube link and category argument (optional) to decide if the categories should be returned in the transcription response.
Checking Transcription Status
To check if the audio file has been transcribed, use the polling endpoint with the transcript endpoint URL and the audio file's ID. Add communication to inform the user that the transcription process has started. Return the polling endpoint to the Streamlit application to check for completion.
Conclusion
In this tutorial, we have set up the project structure, installed dependencies, created the base Streamlit application, and integrated YouTube downloading and transcription functionality using Assembly AI. In the next part, we will focus on enhancing the Streamlit application and improving the user interface.
Highlights:
- Build a web app using Streamlit and Assembly AI.
- Transcribe YouTube videos just from their link.
- Two-part tutorial for coding and improving the user interface.
- Display YouTube videos and their transcriptions in a user-friendly app.
- Assembly AI provides easy-to-use API for accurate audio and video file transcriptions.
- Sign up for a free Assembly AI account to follow along.
- Install Streamlit, YouTube DL, and ffmpeg libraries.
- Create the base Streamlit application with a title and text input for YouTube links.
- Set up YouTube downloader functionality using the YouTube DL library.
- Configure options and constants for using the ffmpeg library.
- Integrate Assembly AI API for audio file transcription.
- Check the transcription status using the polling endpoint.
- Complete the first part of the tutorial with the transcription process.
FAQ:
Q: How do I install Streamlit?
A: You can install Streamlit by running the command "pip install streamlit" in your terminal.
Q: Can I use a free Assembly AI account for this tutorial?
A: Yes, you can sign up for a free Assembly AI account and use the provided free API token.
Q: How do I set up the ffmpeg library on Windows?
A: Download the correct ffmpeg files for your system and place them in a specific location. Update the path in the configuration file to ensure your application can find and run the executables.
Q: How can I check if the transcription process is complete?
A: You can use the polling endpoint provided by Assembly AI to check the transcription status using the transcript endpoint URL and the audio file's ID.
Q: Can I customize the Streamlit application further in the next tutorial?
A: Yes, in the next part of the tutorial, we will focus on enhancing the Streamlit application and improving the user interface.