Translations
Create translation
TranslationCreateResponse audio().translations().create(TranslationCreateParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
post /audio/translations
Translates audio into English.
Parameters
-
TranslationCreateParams params-
String fileThe audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
-
AudioModel modelID of the model to use. Only
whisper-1(which is powered by our open source Whisper V2 model) is currently available. -
Optional<String> promptAn optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.
-
Optional<ResponseFormat> responseFormatThe format of the output, in one of these options:
json,text,srt,verbose_json, orvtt.-
JSON("json") -
TEXT("text") -
SRT("srt") -
VERBOSE_JSON("verbose_json") -
VTT("vtt")
-
-
Optional<Double> temperatureThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
-
Returns
-
class TranslationCreateResponse: A class that can be one of several variants.union-
class Translation:String text
-
class TranslationVerbose:-
double durationThe duration of the input audio.
-
String languageThe language of the output translation (always
english). -
String textThe translated text.
-
Optional<List<TranscriptionSegment>> segmentsSegments of the translated text and their corresponding details.
-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
-
-
Example
package com.openai.example;
import com.openai.client.OpenAIClient;
import com.openai.client.okhttp.OpenAIOkHttpClient;
import com.openai.models.audio.AudioModel;
import com.openai.models.audio.translations.TranslationCreateParams;
import com.openai.models.audio.translations.TranslationCreateResponse;
import java.io.ByteArrayInputStream;
public final class Main {
private Main() {}
public static void main(String[] args) {
OpenAIClient client = OpenAIOkHttpClient.fromEnv();
TranslationCreateParams params = TranslationCreateParams.builder()
.file(new ByteArrayInputStream("Example data".getBytes()))
.model(AudioModel.WHISPER_1)
.build();
TranslationCreateResponse translation = client.audio().translations().create(params);
}
}
Response
{
"text": "text"
}
Domain Types
Translation
-
class Translation:String text
Translation Verbose
-
class TranslationVerbose:-
double durationThe duration of the input audio.
-
String languageThe language of the output translation (always
english). -
String textThe translated text.
-
Optional<List<TranscriptionSegment>> segmentsSegments of the translated text and their corresponding details.
-
long idUnique identifier of the segment.
-
double avgLogprobAverage logprob of the segment. If the value is lower than -1, consider the logprobs failed.
-
double compressionRatioCompression ratio of the segment. If the value is greater than 2.4, consider the compression failed.
-
double endEnd time of the segment in seconds.
-
double noSpeechProbProbability of no speech in the segment. If the value is higher than 1.0 and the
avg_logprobis below -1, consider this segment silent. -
long seekSeek offset of the segment.
-
double startStart time of the segment in seconds.
-
double temperatureTemperature parameter used for generating the segment.
-
String textText content of the segment.
-
List<long> tokensArray of token IDs for the text content.
-
-