Skip to main content
Last Updated: January 15, 2025 YouTube URLs are not natively downloadable, which can be a challenge when working with the Salad Transcription API, which requires downloadable audio links. However, you can extract audio from YouTube videos, upload it to Salad Simple Storage Service free of charge, and use the resulting link with the API. This guide will walk you through the process, starting with handling a single YouTube URL and then scaling to batch processing multiple URLs.

Prerequisites

Before you begin, make sure you have:
  1. Python Installed: Ensure you have Python 3.8 or higher.
  2. Libraries Installed: Use the following command to install the required libraries:
  3. 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.
  4. 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:
2. Upload Audio to Salad Storage This function uploads the audio file to Salad Storage and generates a presigned URL:

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:
Signed Salad Storage URL will be printed and stored under storage_url.

Step 5: Batch Process Multiple URLs

To process multiple YouTube URLs, use the following script:
Expected Output: A url_mappings.json file is generated with the mappings:

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 the job_id. Function to Send a Transcription Request This function sends a transcription request to the Salad Transcription API for a single URL:
Usage Example Here is how you can use the function to submit a transcription request: All the parameters needed for the function were already defined in the previous steps.
Expected Output If the request is successful, the API will return a job_id and our function will print it out:
The job_id is a unique identifier for the transcription job. You can use it later to check the job status or retrieve the final result. Note If you have multiple audio files to process, you can loop through the list of URLs and call this function for each one to retrieve a list of job_ids.

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:
Usage Example Here is how to use the function to retrieve the result:
Expected Output If the job is still processing:
If the job is completed:
Note
  • 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.