Customizing Transcription with Language and Prompt Parameters

Introduction: Why Customize Transcription?

Welcome to the first lesson of the course, where we will explore how to make your audio transcriptions smarter and more accurate by customizing the transcription process. In many real-world situations, audio files can be in different languages or contain specific topics, names, or jargon. By customizing the transcription settings, you can help the model understand your audio better and produce more accurate results.

In this lesson, you will learn how to use custom parameters — specifically, the language and prompt options — when transcribing audio with OpenAI GPT-4o Mini in Java using direct HTTP requests. These options allow you to tell the model what language to expect and give it extra context about the audio, which can be very helpful for meetings, interviews, or technical discussions.

Recall: Basic Transcription with HTTP Requests

Before we dive into custom parameters, let's remind ourselves how a basic transcription works using direct HTTP requests. In a simple setup, you provide an audio file to the model via a multipart/form-data POST request, and it returns the text it hears using default settings.

For example, in previous lessons, you might have seen code like this:

Java
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;

// Basic transcription request
// Create a unique boundary to separate form data parts
String boundary = "----boundary" + System.currentTimeMillis();
// Build the multipart form data with audio file
byte[] formData = buildBasicFormData(audioFile, boundary);

// Create HTTP POST request to the transcription endpoint
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create(baseUrl + "/v1/audio/transcriptions"))
    .header("Authorization", "Bearer " + apiKey) // API authentication
    .header("Content-Type", "multipart/form-data; boundary=" + boundary) // Specify form data type
    .POST(HttpRequest.BodyPublishers.ofByteArray(formData)) // Send form data as request body
    .build();

// Send the request and get the response
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());

This code sends an audio file to the model and returns the transcribed text. By default, the model tries to detect the language and does not use any extra context.

Sign up

Join the 1M+ learners on CodeSignal

Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal