音频模型
1. Speech-to-text(语音转文本)
将音频文件转为文本。
请求说明
基本信息
- 请求地址:
https://model.sophnet.com/api/open-apis/projects/easyllms/speechtotext/non-stream - 请求方式:POST
Header 参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Content-Type | String | 是 | 固定值 application/json |
| Authorization | String | 是 | "Bearer " + API Key |
Body 参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| audio_url | string | 是 | 音频文件 URL 地址 |
请求示例
BASH
curl --location --request POST https://model.sophnet.com/api/open-apis/projects/easyllms/speechtotext/non-stream \
--header "Authorization: Bearer $API_KEY" \
--header "Content-Type: application/json" \
--data-raw '{
"audio_url": "https://example.com/audio.mp3"
}'2. Text-to-Voice(CosyVoice 语音合成)
通过 CosyVoice 模型进行高质量语音合成,支持精细的语音参数调节。
请求说明
基本信息
- 请求地址:
https://model.sophnet.com/api/open-apis/projects/easyllms/voice/synthesize-audio - 请求方式:POST
Header 参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Content-Type | String | 是 | 固定值 application/json |
| Authorization | String | 是 | "Bearer " + API Key |
Body 参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| text | array | 是 | 待合成文本数组 |
| synthesis_param.model | string | 是 | 模型名称,如 "cosyvoice-v2" |
| synthesis_param.voice | string | 是 | 音色,如 "longjiqi" |
| synthesis_param.format | string | 否 | 输出格式,如 "MP3_16000HZ_MONO_128KBPS" |
| synthesis_param.volume | integer | 否 | 音量,取值范围 0-100,默认 80 |
| synthesis_param.speechRate | number | 否 | 语速,默认 1.0 |
| synthesis_param.pitchRate | number | 否 | 音调,默认 1.0 |
Python SDK 示例
PYTHON
import requests
import json
API_KEY = "YOUR_API_KEY"
url = "https://model.sophnet.com/api/open-apis/projects/easyllms/voice/synthesize-audio"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer " + API_KEY,
}
payload = json.dumps({
"text": ["测试"],
"synthesis_param": {
"model": "cosyvoice-v2",
"voice": "longjiqi",
"format": "MP3_16000HZ_MONO_128KBPS",
"volume": 80,
"speechRate": 1.2,
"pitchRate": 1
}
})
response = requests.request("POST", url, headers=headers, data=payload)
with open("output.mp3", "wb") as f:
f.write(response.content)