跳到主要内容

音频与语音

本页汇总语音生成、语音转文本与音频翻译相关接口。

Apifox 覆盖范围补充

  • 原生 OpenAI 格式:TTS、whisper-1gpt-4o-transcribe、音频翻译、Audio 输出、Audio 输入
  • 厂商扩展:MiniMax 语音合成、豆包语音 2.0
  • 原生 Gemini 格式:Gemini 音频生成 / 语音接口

模型接口/音频(Audio)

POST 原生Gemini格式

POST /v1beta/models/{model}:generateContent

Gemini 音频生成接口。 可使用gemini-2.5-flash-preview-tts等模型

Body 请求参数

{
"contents": [
{
"parts": [
{
"text": "Say cheerfully: Have a wonderful day!"
}
]
}
],
"generationConfig": {
"responseModalities": [
"AUDIO"
],
"speechConfig": {
"voiceConfig": {
"prebuiltVoiceConfig": {
"voiceName": "Kore"
}
}
}
}
}

请求参数

名称位置类型必选说明
modelpathstring模型名称
keyquerystringnone
Content-Typeheaderstringnone
bodybodyobjectnone
» contentsbody[object]none
»» partsbody[object]none
»»» textbodystringnone

返回示例

200 Response

{
"id": "string",
"object": "string",
"created": 0,
"choices": [
{
"index": 0,
"message": {
"role": "string",
"content": "string"
},
"finish_reason": "string"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}

返回结果

状态码状态码含义说明数据模型
200OKnoneInline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» idstringtruenonenone
» objectstringtruenonenone
» createdintegertruenonenone
» choices[object]truenonenone
»» indexintegerfalsenonenone
»» messageobjectfalsenonenone
»»» rolestringtruenonenone
»»» contentstringtruenonenone
»» finish_reasonstringfalsenonenone
» usageobjecttruenonenone
»» prompt_tokensintegertruenonenone
»» completion_tokensintegertruenonenone
»» total_tokensintegertruenonenone

模型接口/音频(Audio)/原生OpenAI格式

POST 豆包语音2.0

POST /audio/speech

每个音色能支持的情感不同, 具体参考音色情感列表: https://www.volcengine.com/docs/6561/1257544 开心(happy),悲伤(sad),生气(angry),惊讶(surprised),恐惧(fear)... 所有在openai标准之外的参数按原厂格式写在metadata里, 支持所有格式 音色示例: 通过调整emotion参数

Body 请求参数

{
"input": "你是一个好孩子",
"model": "seed-tts-1.1",
"response_format": "mp3",
"speed": 1,
"voice": "zh_female_shuangkuaisisi_emo_v2_mars_bigtts",
"metadata": {
"audio": {
"emotion_scale": 5,
"enable_emotion": true,
"emotion": "happy"
}
}
}

请求参数

名称位置类型必选说明
Content-Typeheaderstringnone
Authorizationheaderstringnone
bodybodyobjectnone
» modelbodystring可用的 TTS 模型之一:tts-1 或 tts-1-hd
» inputbodystring要生成音频的文本。最大长度为4096个字符。
» voicebodystring生成音频时使用的语音。支持的语音有:alloy、echo、fable、onyx、nova 和 shimmer。
» response_formatbodystring默认为 mp3 音频的格式。支持的格式有:mp3、opus、aac 和 flac。
» speedbodynumber默认为 1 生成的音频速度。选择0.25到4.0之间的值。1.0是默认值。

返回示例

200 Response

{}

返回结果

状态码状态码含义说明数据模型
200OKnoneInline

返回数据结构

POST 语音转文本 / gpt-4o-transcribe

POST /audio/transcriptions

官方文档:https://platform.openai.com/docs/api-reference/audio/createTranscription

Body 请求参数

file: file:///Users/jun/Downloads/response.wav
model: gpt-4o-transcribe
prompt: eiusmod nulla
response_format: json
temperature: 0
language: ""

请求参数

名称位置类型必选说明
Content-Typeheaderstringnone
Acceptheaderstringnone
Authorizationheaderstringnone
bodybodyobjectnone
» filebodystring(binary)要转录的音频文件,采用以下格式之一:mp3、mp4、mpeg、mpga、m4a、wav 或 webm。
» modelbodystring要使用的模型的 ID。仅whisper-1当前可用。
» promptbodystring可选文本,用于指导模型的风格或继续之前的音频片段。提示应音频语言相匹配。
» response_formatbodystringnone
» temperaturebodynumber采样温度,介于 0 和 1 之间。较高的值(如 0.8)将使输出更加随机,而较低的值(如 0.2)将使输出更加集中和确定。如果设置为 0,模型将使用对数概率自动升高温度,直到达到特定阈值。
» languagebodystring输入音频的语言。以ISO-639-1格式提供输入语言将提高准确性和延迟。

返回示例

200 Response

{
"text": "string"
}

返回结果

状态码状态码含义说明数据模型
200OKnoneInline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» textstringtruenonenone

POST 音频翻译

POST /audio/translations

将音频翻译成英文。

Body 请求参数

file: string
model: whisper-1
prompt: ""
response_format: verbose_json
temperature: 0

请求参数

名称位置类型必选说明
Content-Typeheaderstringnone
Acceptheaderstringnone
Authorizationheaderstringnone
bodybodyobjectnone
» filebodystring(binary)要翻译的音频文件,支持以下格式:mp3,mp4,mpeg,mpga,m4a,wav 或 webm。
» modelbodystring(要使用的模型的 ID,目前仅有 whisper-1 可用。
» promptbodystring一个可选的文本,用于指导模型的风格或继续先前的音频片段。 prompt 应为英文。
» response_formatbodystring转录输出的格式,支持以下选项之一:json、text、srt、verbose_json 或 vtt。
» temperaturebodynumber采样温度,介于 0 和 1 之间。 较高的值(如 0.8)将使输出更随机,而较低的值(如 0.2)将使其更加专注和确定性。 如果设置为 0,则模型将使用对数概率自动增加温度,直到达到一定的阈值。

返回示例

200 Response

{
"text": "string"
}

返回结果

状态码状态码含义说明数据模型
200OKnoneInline

返回数据结构

状态码 200

名称类型必选约束中文名说明
» textstringtruenonenone