跳转到主要内容
POST
/
v3
/
fish-audio-s2-pro-text-to-speech
Fish Audio S2 Pro Text to Speech
curl --request POST \
  --url https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "text": "<string>",
  "top_p": 123,
  "format": "<string>",
  "latency": "<string>",
  "prosody": {
    "speed": 123,
    "volume": 123,
    "normalize_loudness": true
  },
  "normalize": true,
  "references": [
    {
      "text": "<string>",
      "audio": "<string>"
    }
  ],
  "mp3_bitrate": 123,
  "sample_rate": 123,
  "temperature": 123,
  "chunk_length": 123,
  "opus_bitrate": 123,
  "reference_id": "<string>",
  "max_new_tokens": 123,
  "min_chunk_length": 123,
  "repetition_penalty": 123,
  "early_stop_threshold": 123,
  "condition_on_previous_chunks": true
}
'
import requests

url = "https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech"

payload = {
"text": "<string>",
"top_p": 123,
"format": "<string>",
"latency": "<string>",
"prosody": {
"speed": 123,
"volume": 123,
"normalize_loudness": True
},
"normalize": True,
"references": [
{
"text": "<string>",
"audio": "<string>"
}
],
"mp3_bitrate": 123,
"sample_rate": 123,
"temperature": 123,
"chunk_length": 123,
"opus_bitrate": 123,
"reference_id": "<string>",
"max_new_tokens": 123,
"min_chunk_length": 123,
"repetition_penalty": 123,
"early_stop_threshold": 123,
"condition_on_previous_chunks": True
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
text: '<string>',
top_p: 123,
format: '<string>',
latency: '<string>',
prosody: {speed: 123, volume: 123, normalize_loudness: true},
normalize: true,
references: [{text: '<string>', audio: '<string>'}],
mp3_bitrate: 123,
sample_rate: 123,
temperature: 123,
chunk_length: 123,
opus_bitrate: 123,
reference_id: '<string>',
max_new_tokens: 123,
min_chunk_length: 123,
repetition_penalty: 123,
early_stop_threshold: 123,
condition_on_previous_chunks: true
})
};

fetch('https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'top_p' => 123,
'format' => '<string>',
'latency' => '<string>',
'prosody' => [
'speed' => 123,
'volume' => 123,
'normalize_loudness' => true
],
'normalize' => true,
'references' => [
[
'text' => '<string>',
'audio' => '<string>'
]
],
'mp3_bitrate' => 123,
'sample_rate' => 123,
'temperature' => 123,
'chunk_length' => 123,
'opus_bitrate' => 123,
'reference_id' => '<string>',
'max_new_tokens' => 123,
'min_chunk_length' => 123,
'repetition_penalty' => 123,
'early_stop_threshold' => 123,
'condition_on_previous_chunks' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech"

payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"top_p\": 123,\n \"format\": \"<string>\",\n \"latency\": \"<string>\",\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123,\n \"normalize_loudness\": true\n },\n \"normalize\": true,\n \"references\": [\n {\n \"text\": \"<string>\",\n \"audio\": \"<string>\"\n }\n ],\n \"mp3_bitrate\": 123,\n \"sample_rate\": 123,\n \"temperature\": 123,\n \"chunk_length\": 123,\n \"opus_bitrate\": 123,\n \"reference_id\": \"<string>\",\n \"max_new_tokens\": 123,\n \"min_chunk_length\": 123,\n \"repetition_penalty\": 123,\n \"early_stop_threshold\": 123,\n \"condition_on_previous_chunks\": true\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"text\": \"<string>\",\n \"top_p\": 123,\n \"format\": \"<string>\",\n \"latency\": \"<string>\",\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123,\n \"normalize_loudness\": true\n },\n \"normalize\": true,\n \"references\": [\n {\n \"text\": \"<string>\",\n \"audio\": \"<string>\"\n }\n ],\n \"mp3_bitrate\": 123,\n \"sample_rate\": 123,\n \"temperature\": 123,\n \"chunk_length\": 123,\n \"opus_bitrate\": 123,\n \"reference_id\": \"<string>\",\n \"max_new_tokens\": 123,\n \"min_chunk_length\": 123,\n \"repetition_penalty\": 123,\n \"early_stop_threshold\": 123,\n \"condition_on_previous_chunks\": true\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.highwayapi.ai/v3/fish-audio-s2-pro-text-to-speech")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"text\": \"<string>\",\n \"top_p\": 123,\n \"format\": \"<string>\",\n \"latency\": \"<string>\",\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123,\n \"normalize_loudness\": true\n },\n \"normalize\": true,\n \"references\": [\n {\n \"text\": \"<string>\",\n \"audio\": \"<string>\"\n }\n ],\n \"mp3_bitrate\": 123,\n \"sample_rate\": 123,\n \"temperature\": 123,\n \"chunk_length\": 123,\n \"opus_bitrate\": 123,\n \"reference_id\": \"<string>\",\n \"max_new_tokens\": 123,\n \"min_chunk_length\": 123,\n \"repetition_penalty\": 123,\n \"early_stop_threshold\": 123,\n \"condition_on_previous_chunks\": true\n}"

response = http.request(request)
puts response.read_body
Fish Audio S2 Pro 文本转语音模型,将文本转换为自然语音,支持参考音色、采样控制、分段、音频格式和韵律控制。

请求头

Content-Type
string
必填
枚举值: application/json
Authorization
string
必填
Bearer 身份验证格式: Bearer {{API 密钥}}。

请求体

text
string
必填
需要转换为语音的文本。S2-Pro 多说话人文本可使用 <|speaker:0|>你好<|speaker:1|>你好呀 标签。
top_p
number
核采样多样性控制。取值范围:[0, 1]
format
string
默认值:"mp3"
输出音频格式。可选值:wav, pcm, mp3, opus
latency
string
默认值:"normal"
延迟档位。可选值:low, normal, balanced
prosody
object
韵律控制。
normalize
boolean
默认值:true
对中英文文本进行规范化。
references
object[]
用于零样本声音克隆的参考音频样本。
mp3_bitrate
integer
默认值:128
MP3 比特率,单位 kbps。可选值:64, 128, 192
sample_rate
integer
输出采样率 Hz。为空时使用格式默认值,opus 为 48000 Hz,其他通常为 44100 Hz。
temperature
number
表现力控制。取值范围:[0, 1]
chunk_length
integer
默认值:300
文本分段大小。取值范围:[100, 300]
opus_bitrate
integer
Opus 比特率,单位 bps,-1000 表示自动。可选值:-1000, 24000, 32000, 48000, 64000
reference_id
string
音色模型 ID;多说话人场景可传入与 speaker 索引匹配的数组。
max_new_tokens
integer
默认值:1024
每个分段的最大音频 token 数。
min_chunk_length
integer
默认值:50
分段前的最小字符数。取值范围:[0, 100]
repetition_penalty
number
降低音频模式重复的惩罚系数。
early_stop_threshold
number
默认值:1
提前停止阈值。取值范围:[0, 1]
condition_on_previous_chunks
boolean
默认值:true
使用前序音频分段作为上下文。

响应信息

生成的音频。 格式: binary