Skip to main content
In this tutorial, we’ll demonstrate how to translate a short Spanish audio clip into English text using OpenAI’s Whisper API. We’ll process a 20-second MP3 segment (up to 25 MB) extracted from an Easy Spanish YouTube video and send it to the API in one request.

Prerequisites

  • Python 3.7+
  • openai Python SDK
  • An OpenAI API key
Install the SDK with:
Ensure your MP3 file is under 25 MB. Whisper supports formats like MP3, WAV, and FLAC.

Translation Code Example

Step-by-Step Breakdown

Keep your API key secure. Do not hard-code it in public repositories.

Next Steps

Once you have the translated text, you can pass it to GPT-4 (or any other LLM) for further processing—such as summarization, sentiment analysis, or content moderation.

Watch Video

Practice Lab