音訊與語音
本頁彙總語音生成、語音轉文本與音頻翻譯相關接口。
Apifox 覆蓋範圍補充
- 原生 OpenAI 格式:TTS、
whisper-1、gpt-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"
}
}
}
}
}
請求參數
| 名稱 | 位置 | 類型 | 必選 | 說明 |
|---|---|---|---|---|
| model | path | string | 是 | 模型名稱 |
| key | query | string | 是 | none |
| Content-Type | header | string | 是 | none |
| body | body | object | 否 | none |
| » contents | body | [object] | 是 | none |
| »» parts | body | [object] | 否 | none |
| »»» text | body | string | 否 | none |
返回示例
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
}
}
返回結果
| 狀態碼 | 狀態碼含義 | 說明 | 數據模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
返回數據結構
狀態碼 200
| 名稱 | 類型 | 必選 | 約束 | 中文名 | 說明 |
|---|---|---|---|---|---|
| » id | string | true | none | none | |
| » object | string | true | none | none | |
| » created | integer | true | none | none | |
| » choices | [object] | true | none | none | |
| »» index | integer | false | none | none | |
| »» message | object | false | none | none | |
| »»» role | string | true | none | none | |
| »»» content | string | true | none | none | |
| »» finish_reason | string | false | none | none | |
| » usage | object | true | none | none | |
| »» prompt_tokens | integer | true | none | none | |
| »» completion_tokens | integer | true | none | none | |
| »» total_tokens | integer | true | none | none |
模型接口/音頻(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-Type | header | string | 是 | none |
| Authorization | header | string | 是 | none |
| body | body | object | 否 | none |
| » model | body | string | 是 | 可用的 TTS 模型之一:tts-1 或 tts-1-hd |
| » input | body | string | 是 | 要生成音頻的文本。最大長度為4096個字符。 |
| » voice | body | string | 是 | 生成音頻時使用的語音。支持的語音有:alloy、echo、fable、onyx、nova 和 shimmer。 |
| » response_format | body | string | 否 | 默認為 mp3 音頻的格式。支持的格式有:mp3、opus、aac 和 flac。 |
| » speed | body | number | 否 | 默認為 1 生成的音頻速度。選擇0.25到4.0之間的值。1.0是默認值。 |
返回示例
200 Response
{}
返回結果
| 狀態碼 | 狀態碼含義 | 說明 | 數據模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
返回數據結構
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-Type | header | string | 是 | none |
| Accept | header | string | 是 | none |
| Authorization | header | string | 否 | none |
| body | body | object | 否 | none |
| » file | body | string(binary) | 是 | 要轉錄的音頻文件,採用以下格式之一:mp3、mp4、mpeg、mpga、m4a、wav 或 webm。 |
| » model | body | string | 是 | 要使用的模型的 ID。僅whisper-1當前可用。 |
| » prompt | body | string | 否 | 可選文本,用於指導模型的風格或繼續之前的音頻片段。提示應與音頻語言相匹配。 |
| » response_format | body | string | 否 | none |
| » temperature | body | number | 否 | 採樣溫度,介於 0 和 1 之間。較高的值(如 0.8)將使輸出更加隨機,而較低的值(如 0.2)將使輸出更加集中和確定。如果設置為 0,模型將使用對數概率自動升高溫度,直到達到特定閾值。 |
| » language | body | string | 否 | 輸入音頻的語言。以ISO-639-1格式提供輸入語言將提高準確性和延遲。 |
返回示例
200 Response
{
"text": "string"
}
返回結果
| 狀態碼 | 狀態碼含義 | 說明 | 數據模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
返回數據結構
狀態碼 200
| 名稱 | 類型 | 必選 | 約束 | 中文名 | 說明 |
|---|---|---|---|---|---|
| » text | string | true | none | none |
POST 音頻翻譯
POST /audio/translations
將音頻翻譯成英文。
Body 請求參數
file: string
model: whisper-1
prompt: ""
response_format: verbose_json
temperature: 0
請求參數
| 名稱 | 位置 | 類型 | 必選 | 說明 |
|---|---|---|---|---|
| Content-Type | header | string | 是 | none |
| Accept | header | string | 是 | none |
| Authorization | header | string | 否 | none |
| body | body | object | 否 | none |
| » file | body | string(binary) | 是 | 要翻譯的音頻文件,支持以下格式:mp3,mp4,mpeg,mpga,m4a,wav 或 webm。 |
| » model | body | string | 是 | (要使用的模型的 ID,目前僅有 whisper-1 可用。 |
| » prompt | body | string | 否 | 一個可選的文本,用於指導模型的風格或繼續先前的音頻片段。 prompt 應為英文。 |
| » response_format | body | string | 否 | 轉錄輸出的格式,支持以下選項之一:json、text、srt、verbose_json 或 vtt。 |
| » temperature | body | number | 否 | 採樣溫度,介於 0 和 1 之間。 較高的值(如 0.8)將使輸出更隨機,而較低的值(如 0.2)將使其更加專注和確定性。 如果設置為 0,則模型將使用對數概率自動增加溫度,直到達到一定的閾值。 |
返回示例
200 Response
{
"text": "string"
}
返回結果
| 狀態碼 | 狀態碼含義 | 說明 | 數據模型 |
|---|---|---|---|
| 200 | OK | none | Inline |
返回數據結構
狀態碼 200
| 名稱 | 類型 | 必選 | 約束 | 中文名 | 說明 |
|---|---|---|---|---|---|
| » text | string | true | none | none |