Skip to content

音频翻译

将音频文件翻译并转录为英文文本。

接口详情

接口地址: POST /v1/audio/translations

功能描述: 将任何支持的语言音频文件翻译为英文文本。支持多种音频格式。

认证方式: Bearer Token

http
Authorization: Bearer YOUR_API_TOKEN

请求参数

Header 参数

参数名类型必填说明示例
AuthorizationstringBearer Token 认证Bearer sk-xxx...
Content-Typestring内容类型multipart/form-data

Body 参数 (Multipart Form Data)

参数名类型必填说明示例
filefile要翻译的音频文件speech.mp3
modelstring使用的模型 IDwhisper-1
promptstring用于指导模型风格或继续翻译的提示文本-
response_formatstring响应格式 (json, text, srt, vtt)json
temperaturenumber采样温度 (0-1 之间)0

响应参数

响应格式: 默认返回 JSON 格式的翻译后英文文本。

json
{
  "text": "Hello, this is a translated text from audio."
}

代码示例

Python (使用 OpenAI SDK)

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.ezmodel.cloud/v1"
)

audio_file = open("german_speech.mp3", "rb")
translation = client.audio.translations.create(
  model="whisper-1", 
  file=audio_file
)

print(translation.text)

Curl 示例

bash
curl https://api.ezmodel.cloud/v1/audio/translations \
  -H "Authorization: Bearer $YOUR_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@german_speech.mp3" \
  -F model="whisper-1"

OpenAPI Specification

yaml
openapi: 3.0.1
info:
  title: ''
  description: ''
  version: 1.0.0
paths:
  /v1/audio/translations:
    post:
      summary: 音频翻译
      description: 将音频文件翻译为英文文本。
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
                - model
              properties:
                file:
                  type: string
                  format: binary
                model:
                  type: string
      responses:
        '200':
          description: 成功翻译音频
          content:
            application/json:
              schema:
                type: object
                properties:
                  text:
                    type: string

企业合作联系:service@ezmodel.cloud