Fish Audio 语音合成
curl --request POST \
--url https://api.highwayapi.ai/v4beta/txt2speech \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"text": "<string>",
"temperature": 123,
"top_p": 123,
"references": {
"text": "<string>"
},
"reference_id": {},
"prosody": {
"speed": 123,
"volume": 123
},
"chunk_length": 123,
"normalize": true,
"format": {},
"sample_rate": {},
"mp3_bitrate": {},
"opus_bitrate": {},
"latency": {}
}
'import requests
url = "https://api.highwayapi.ai/v4beta/txt2speech"
payload = {
"text": "<string>",
"temperature": 123,
"top_p": 123,
"references": { "text": "<string>" },
"reference_id": {},
"prosody": {
"speed": 123,
"volume": 123
},
"chunk_length": 123,
"normalize": True,
"format": {},
"sample_rate": {},
"mp3_bitrate": {},
"opus_bitrate": {},
"latency": {}
}
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>',
temperature: 123,
top_p: 123,
references: {text: '<string>'},
reference_id: {},
prosody: {speed: 123, volume: 123},
chunk_length: 123,
normalize: true,
format: {},
sample_rate: {},
mp3_bitrate: {},
opus_bitrate: {},
latency: {}
})
};
fetch('https://api.highwayapi.ai/v4beta/txt2speech', 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/v4beta/txt2speech",
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>',
'temperature' => 123,
'top_p' => 123,
'references' => [
'text' => '<string>'
],
'reference_id' => [
],
'prosody' => [
'speed' => 123,
'volume' => 123
],
'chunk_length' => 123,
'normalize' => true,
'format' => [
],
'sample_rate' => [
],
'mp3_bitrate' => [
],
'opus_bitrate' => [
],
'latency' => [
]
]),
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/v4beta/txt2speech"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"references\": {\n \"text\": \"<string>\"\n },\n \"reference_id\": {},\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123\n },\n \"chunk_length\": 123,\n \"normalize\": true,\n \"format\": {},\n \"sample_rate\": {},\n \"mp3_bitrate\": {},\n \"opus_bitrate\": {},\n \"latency\": {}\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/v4beta/txt2speech")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"text\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"references\": {\n \"text\": \"<string>\"\n },\n \"reference_id\": {},\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123\n },\n \"chunk_length\": 123,\n \"normalize\": true,\n \"format\": {},\n \"sample_rate\": {},\n \"mp3_bitrate\": {},\n \"opus_bitrate\": {},\n \"latency\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.highwayapi.ai/v4beta/txt2speech")
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 \"temperature\": 123,\n \"top_p\": 123,\n \"references\": {\n \"text\": \"<string>\"\n },\n \"reference_id\": {},\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123\n },\n \"chunk_length\": 123,\n \"normalize\": true,\n \"format\": {},\n \"sample_rate\": {},\n \"mp3_bitrate\": {},\n \"opus_bitrate\": {},\n \"latency\": {}\n}"
response = http.request(request)
puts response.read_body音频
Fish Audio 语音合成
POST
/
v4beta
/
txt2speech
Fish Audio 语音合成
curl --request POST \
--url https://api.highwayapi.ai/v4beta/txt2speech \
--header 'Authorization: <authorization>' \
--header 'Content-Type: <content-type>' \
--data '
{
"text": "<string>",
"temperature": 123,
"top_p": 123,
"references": {
"text": "<string>"
},
"reference_id": {},
"prosody": {
"speed": 123,
"volume": 123
},
"chunk_length": 123,
"normalize": true,
"format": {},
"sample_rate": {},
"mp3_bitrate": {},
"opus_bitrate": {},
"latency": {}
}
'import requests
url = "https://api.highwayapi.ai/v4beta/txt2speech"
payload = {
"text": "<string>",
"temperature": 123,
"top_p": 123,
"references": { "text": "<string>" },
"reference_id": {},
"prosody": {
"speed": 123,
"volume": 123
},
"chunk_length": 123,
"normalize": True,
"format": {},
"sample_rate": {},
"mp3_bitrate": {},
"opus_bitrate": {},
"latency": {}
}
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>',
temperature: 123,
top_p: 123,
references: {text: '<string>'},
reference_id: {},
prosody: {speed: 123, volume: 123},
chunk_length: 123,
normalize: true,
format: {},
sample_rate: {},
mp3_bitrate: {},
opus_bitrate: {},
latency: {}
})
};
fetch('https://api.highwayapi.ai/v4beta/txt2speech', 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/v4beta/txt2speech",
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>',
'temperature' => 123,
'top_p' => 123,
'references' => [
'text' => '<string>'
],
'reference_id' => [
],
'prosody' => [
'speed' => 123,
'volume' => 123
],
'chunk_length' => 123,
'normalize' => true,
'format' => [
],
'sample_rate' => [
],
'mp3_bitrate' => [
],
'opus_bitrate' => [
],
'latency' => [
]
]),
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/v4beta/txt2speech"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"references\": {\n \"text\": \"<string>\"\n },\n \"reference_id\": {},\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123\n },\n \"chunk_length\": 123,\n \"normalize\": true,\n \"format\": {},\n \"sample_rate\": {},\n \"mp3_bitrate\": {},\n \"opus_bitrate\": {},\n \"latency\": {}\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/v4beta/txt2speech")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"text\": \"<string>\",\n \"temperature\": 123,\n \"top_p\": 123,\n \"references\": {\n \"text\": \"<string>\"\n },\n \"reference_id\": {},\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123\n },\n \"chunk_length\": 123,\n \"normalize\": true,\n \"format\": {},\n \"sample_rate\": {},\n \"mp3_bitrate\": {},\n \"opus_bitrate\": {},\n \"latency\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.highwayapi.ai/v4beta/txt2speech")
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 \"temperature\": 123,\n \"top_p\": 123,\n \"references\": {\n \"text\": \"<string>\"\n },\n \"reference_id\": {},\n \"prosody\": {\n \"speed\": 123,\n \"volume\": 123\n },\n \"chunk_length\": 123,\n \"normalize\": true,\n \"format\": {},\n \"sample_rate\": {},\n \"mp3_bitrate\": {},\n \"opus_bitrate\": {},\n \"latency\": {}\n}"
response = http.request(request)
puts response.read_body为了获得最佳效果,建议在使用此 API 之前,先使用音频复刻上传参考音频。这将提高语音质量并降低延迟。
-
WAV / PCM
- 采样率:8kHz, 16kHz, 24kHz, 32kHz, 44.1kHz
- 默认采样率:44.1kHz
- 16-bit,单声道
-
MP3
- 采样率:32kHz, 44.1kHz
- 默认采样率:44.1kHz
- 单声道
- 比特率:64kbps, 128kbps (默认), 192kbps
-
Opus
- 采样率:48kHz
- 默认采样率:48kHz
- 单声道
- 比特率:-1000 (自动), 24kbps, 32kbps (默认), 48kbps, 64kbps
请求头
枚举值:
application/jsonBearer 身份验证格式: Bearer {{API 密钥}}。
请求体
要转换为语音的文本。
控制语音生成的随机性。较高的值(例如 1.0)使输出更随机,较低的值(例如 0.1)使其更确定。我们建议
s1 模型使用 0.9。必需范围:0 <= x <= 1通过核采样控制多样性。较低的值(例如 0.1)使输出更集中,较高的值(例如 1.0)允许更多样性。我们建议
s1 模型使用 0.9。必需范围:0 <= x <= 1用于语音的参考模型 ID。
用于语音的分块长度。必需范围:
100 <= x <= 300是否规范化语音,这将降低延迟,但可能会降低对数字和日期的处理性能。
用于语音的格式。可选值:
wav, pcm, mp3, opus用于语音的采样率。
用于语音的 MP3 比特率。可选值:
64, 128, 192用于语音的 Opus 比特率。可选值:
-1000, 24, 32, 48, 64用于语音的延迟设置,balanced 将降低延迟但可能导致性能下降。可选值:
normal, balanced响应信息
API 将直接返回由format 参数指定格式的音频流(默认:mp3)。⌘I