音频模型

1. Speech-to-text(语音转文本)

将音频文件转为文本。

请求说明

基本信息

  • 请求地址:https://model.sophnet.com/api/open-apis/projects/easyllms/speechtotext/non-stream
  • 请求方式:POST

Header 参数

名称类型必填描述
Content-TypeString是固定值 application/json
AuthorizationString是"Bearer " + API Key

Body 参数

名称类型必填描述
audio_urlstring是音频文件 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-TypeString是固定值 application/json
AuthorizationString是"Bearer " + API Key

Body 参数

名称类型必填描述
textarray是待合成文本数组
synthesis_param.modelstring是模型名称,如 "cosyvoice-v2"
synthesis_param.voicestring是音色,如 "longjiqi"
synthesis_param.formatstring否输出格式,如 "MP3_16000HZ_MONO_128KBPS"
synthesis_param.volumeinteger否音量,取值范围 0-100,默认 80
synthesis_param.speechRatenumber否语速,默认 1.0
synthesis_param.pitchRatenumber否音调,默认 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)