音訊處理
完成語音合成、語音轉錄和音訊翻譯。
概述
AGTCloud 的音訊介面覆蓋語音合成、語音轉錄和音訊翻譯。三類任務使用不同的輸入方式,並分別回傳音訊檔案或文字結果。
支援的任務類型
| 類型 | 說明 | 主要結果 |
|---|---|---|
| 語音合成 | 將文字轉換為語音 | 二進位音訊 |
| 語音轉錄 | 將音訊轉換為原語言文字 | JSON、文字或字幕 |
| 音訊翻譯 | 將音訊轉換為英語文字 | JSON、文字或字幕 |
API 串接
Base URL
https://api.agtcloud.cn/v1語音合成
curl 'https://api.agtcloud.cn/v1/audio/speech' \
-H 'Authorization: Bearer your-api-key' \
-H 'Content-Type: application/json' \
--data '{
"model": "MODEL_ID",
"input": "歡迎使用 AGTCloud。",
"voice": "alloy"
}' \
--output speech.mp3| 參數 | 必填 | 說明 |
|---|---|---|
model | 是 | 文字轉語音模型 ID |
input | 是 | 要轉換為語音的文字 |
voice | 是 | 生成語音使用的音色 |
response_format | 否 | 音訊輸出格式 |
speed | 否 | 語音生成速度 |
Speech 回傳音訊位元組,應按實際回應格式儲存,不要作為 JSON 解析。
語音轉錄
curl 'https://api.agtcloud.cn/v1/audio/transcriptions' \
-H 'Authorization: Bearer your-api-key' \
-F 'file=@meeting.mp3' \
-F 'model=MODEL_ID'| 參數 | 必填 | 說明 |
|---|---|---|
file | 是 | 要轉錄的音訊檔案 |
model | 是 | 語音轉錄模型 ID |
language | 否 | 輸入音訊的 ISO-639-1 語言代碼 |
response_format | 否 | 轉錄結果的輸出格式 |
Transcriptions 使用 Multipart 上傳音訊。基礎 JSON 回應中的轉錄文字位於 text 欄位。
音訊翻譯
curl 'https://api.agtcloud.cn/v1/audio/translations' \
-H 'Authorization: Bearer your-api-key' \
-F 'file=@chinese.mp3' \
-F 'model=MODEL_ID'| 參數 | 必填 | 說明 |
|---|---|---|
file | 是 | 要翻譯的非英語音訊檔案 |
model | 是 | 音訊翻譯模型 ID |
prompt | 否 | 用於指導輸出風格的英文文字 |
response_format | 否 | 翻譯結果的輸出格式 |
Translations 回傳英語文字,基礎 JSON 回應中的結果位於 text 欄位。
處理回應
| 介面 | 回應處理 |
|---|---|
| Speech | 根據回應格式儲存二進位音訊 |
| Transcriptions | 按 response_format 處理 JSON、文字或字幕 |
| Translations | 按 response_format 處理英語文字結果 |