Chuyển đến nội dung chính
POST
/
v1
/
audio
/
translations
Python (OpenAI SDK)
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["COMETAPI_KEY"],
    base_url="https://api.cometapi.com/v1"
)

audio_file = open("audio.mp3", "rb")
translation = client.audio.translations.create(
    model="whisper-1",
    file=audio_file
)
print(translation.text)
{
  "text": "Hello, welcome to CometAPI."
}
Dùng endpoint này để dịch âm thanh nói sang văn bản tiếng Anh. Nó phù hợp cho hàng đợi hỗ trợ đa ngôn ngữ, duyệt nội dung media, và các workflow cần một bản ghi tiếng Anh từ âm thanh bằng ngôn ngữ khác.

Yêu cầu đầu tiên

Gửi một tệp âm thanh được hỗ trợ với modelfile. Trước tiên hãy dùng một mẫu ngắn để bạn có thể xác minh việc tải lên, phát hiện ngôn ngữ, và phân tích đầu ra.

Đọc phản hồi

Phản hồi mặc định bao gồm text tiếng Anh đã được dịch. Nếu bạn yêu cầu một định dạng phản hồi khác, hãy phân tích phản hồi theo đúng định dạng đó.

Các bước tiếp theo

Ủy quyền

Authorization
string
header
bắt buộc

Bearer token authentication. Use your CometAPI key.

Nội dung

multipart/form-data
file
file
bắt buộc

The audio file to translate. Supported formats: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm.

model
string
mặc định:whisper-1
bắt buộc

The audio translation model to use. Choose a current speech model from the Models page.

prompt
string

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

response_format
enum<string>
mặc định:json

The output format for the translation.

Tùy chọn có sẵn:
json,
text,
srt,
verbose_json,
vtt
temperature
number
mặc định:0

Sampling temperature between 0 and 1. Higher values produce more random output; lower values are more focused. When set to 0, the model auto-adjusts temperature using log probability.

Phạm vi bắt buộc: 0 <= x <= 1

Phản hồi

200 - application/json

The translation result in English.

text
string
bắt buộc

The translated text in English.