Prerequisites
Before you begin, make sure you have:- Python Installed: Ensure you have Python 3.8 or higher.
- Libraries Installed: Use the following command to install the required libraries:
- FFmpeg Installed: FFmpeg is needed by yt-dlp for processing audio:
- Linux:
sudo apt install ffmpeg
- MacOS:
brew install ffmpeg
- Windows: Download FFmpeg and add it to your system PATH.
- Linux:
- Salad API Key: Ensure you have a valid Salad API key.
Last Updated: January 15, 2025
Step 1: Import Libraries
To start, import the required Python libraries:Step 2: Define Functions
1. Download Audio from YouTube This function downloads the best-quality audio from a YouTube video:Step 3: Define Variables
Set the variables required for the process:Step 4: Process a Single URL
Use the functions to process a single YouTube URL:storage_url
.
Step 5: Batch Process Multiple URLs
To process multiple YouTube URLs, use the following script:Step 6: Send Prepared URLs to the Salad Transcription API
Once the audio files are uploaded to Salad Storage and you have the corresponding signed URLs, the final step is to send these URLs to the Salad Transcription API for processing. You can find detailed instructions on how to send requests a to the Salad Transcription API in the official documentation: Salad Transcription API Documentation Below, we provide a function to send a transcription request to the API and retrieve thejob_id
.
Function to Send a Transcription Request
This function sends a transcription request to the Salad Transcription API for a single URL:
Step 7: Retrieve the Transcription Result
If you did not specify a webhook to receive the result, you can manually retrieve the transcription result using the job_id returned in Step 6. Function to Retrieve Transcription Results This function retrieves the result of a transcription job from the Salad Transcription API:- Check the Status: If the job is still processing, you will need to retry later. Ensure you handle the status in the response appropriately.
- Polling Frequency: Avoid excessive polling. Query the API at reasonable intervals (e.g., every 5-10 seconds) to check if the job is completed.