Přeskočit na hlavní obsah

Tento prohlížeč se už nepodporuje.

Upgradujte na Microsoft Edge, abyste mohli využívat nejnovější funkce, aktualizace zabezpečení a technickou podporu.

Stáhnout Microsoft Edge Další informace o Internet Exploreru a Microsoft Edgi
microsoft-foundry.rest.security.o-auth2-auth

Audio

Create a translation

POST /openai/v1/audio/translations

Creates a translation from the supplied request.

Text požadavku

The multipart request body.

Content-Type: multipart/form-data
file OpenAI.CreateTranslationRequest vyžadováno

The audio file object (not file name) translate, in one of these formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm. The request must include enough format metadata for the file to be identified. We recommend an extension-bearing filename and an appropriate content type.

model string | enum vyžadováno

ID of the model to use. Only whisper-1 (which is powered by our open source Whisper V2 model) is currently available.

Některá z následujících možností:
string
enum
whisper-1
prompt string

An optional text to guide the model's style or continue a previous audio segment. The prompt should be in English.

response_format enum

The format of the output, in one of these options: json, text, srt, verbose_json, or vtt.

jsontextsrtverbose_jsonvtt
temperature OpenAI.CreateTranslationRequest

The 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.

Odpovědi

The request has succeeded.

Text

Content-Type: application/json
Některá z následujících možností:
text string vyžadováno
language string vyžadováno

The language of the output translation (always english).

duration integer vyžadováno

The duration of the input audio.

text string vyžadováno

The translated text.

segments OpenAI.TranscriptionSegment[]

Segments of the translated text and their corresponding details.

Client error

Text

Content-Type: application/json
error OpenAI.Error vyžadováno
code string | null vyžadováno
message string vyžadováno
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Některá z následujících možností:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string vyžadováno

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Server error

Text

Content-Type: application/json
error OpenAI.Error vyžadováno
code string | null vyžadováno
message string vyžadováno
param string | null
type string
misalignment OpenAI.MisalignmentErrorDetailsResource
review_target string | null
error_type string | enum
Některá z následujících možností:
string
enum
potentially_unintended_data_transferpotentially_unintended_data_accesspotentially_unintended_destructive_activityother
detailed_explanation string

The public explanation for this block.

steer OpenAI._MisalignmentSteer
message string vyžadováno

The public continuation instruction.

details OpenAI.Error[]
additionalInfo object
debugInfo object

Žádost

curl https://api.openai.com/v1/audio/translations \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@/path/to/file/german.m4a" \
  -F model="whisper-1"
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),  # This is the default and can be omitted
)
translation = client.audio.translations.create(
    file=b"Example data",
    model="whisper-1",
)
print(translation)
import fs from "fs";
import OpenAI from "openai";

const openai = new OpenAI();

async function main() {
    const translation = await openai.audio.translations.create({
        file: fs.createReadStream("speech.mp3"),
        model: "whisper-1",
    });

    console.log(translation.text);
}
main();
using System;

using OpenAI.Audio;

string audioFilePath = "audio.mp3";

AudioClient client = new(
    model: "whisper-1",
    apiKey: Environment.GetEnvironmentVariable("OPENAI_API_KEY")
);

AudioTranscription transcription = client.TranscribeAudio(audioFilePath);

Console.WriteLine($"{transcription.Text}");
import fs from 'fs';
import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env['OPENAI_API_KEY'], // This is the default and can be omitted
});

const translation = await client.audio.translations.create({
  file: fs.createReadStream('speech.mp3'),
  model: 'whisper-1',
});

console.log(translation);
package main

import (
    "bytes"
    "context"
    "fmt"
    "io"

    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("My API Key"),
    )
    translation, err := client.Audio.Translations.New(context.TODO(), openai.AudioTranslationNewParams{
        File:  io.Reader(bytes.NewBuffer([]byte("Example data"))),
        Model: openai.AudioModelWhisper1,
    })
    if err != nil {
        panic(err.Error())
    }
    fmt.Printf("%+v
", translation)
}
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);
    }
}
require "openai"

openai = OpenAI::Client.new(api_key: "My API Key")

translation = openai.audio.translations.create(file: StringIO.new("Example data"), model: :"whisper-1")

puts(translation)

Response

{
  "text": "Hello, my name is Wolfgang and I come from Germany. Where are you heading today?"
}
cs-cz
Vaše volby ochrany osobních údajů
  • Právní omezení AI
  • Předchozí verze
  • Blog
  • Přispět
  • Ochrana osobních údajů
  • Ochrana osobních zdravotních údajů spotřebitelů
  • Podmínky použití
  • Ochranné známky
  • © Microsoft 2026