Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1be4e12c
authored
Oct 17, 2025
by
feitianbubu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: switch to official TTS only when baseUrl is Volcano's official URL
parent
f052f8ba
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletions
+33
-1
relay/channel/volcengine/adaptor.go
+5
-0
relay/channel/volcengine/tts.go
+28
-1
No files found.
relay/channel/volcengine/adaptor.go
View file @
1be4e12c
...
@@ -71,6 +71,7 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
...
@@ -71,6 +71,7 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
ReqID
:
generateRequestID
(),
ReqID
:
generateRequestID
(),
Text
:
request
.
Input
,
Text
:
request
.
Input
,
Operation
:
"query"
,
Operation
:
"query"
,
Model
:
info
.
OriginModelName
,
},
},
}
}
...
@@ -258,7 +259,11 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
...
@@ -258,7 +259,11 @@ func (a *Adaptor) GetRequestURL(info *relaycommon.RelayInfo) (string, error) {
case
constant
.
RelayModeRerank
:
case
constant
.
RelayModeRerank
:
return
fmt
.
Sprintf
(
"%s/api/v3/rerank"
,
baseUrl
),
nil
return
fmt
.
Sprintf
(
"%s/api/v3/rerank"
,
baseUrl
),
nil
case
constant
.
RelayModeAudioSpeech
:
case
constant
.
RelayModeAudioSpeech
:
// 只有当 baseUrl 是火山默认的官方Url时才改为官方的的TTS接口,否则走透传的New接口
if
baseUrl
==
channelconstant
.
ChannelBaseURLs
[
channelconstant
.
ChannelTypeVolcEngine
]
{
return
"https://openspeech.bytedance.com/api/v1/tts"
,
nil
return
"https://openspeech.bytedance.com/api/v1/tts"
,
nil
}
return
fmt
.
Sprintf
(
"%s/v1/audio/speech"
,
baseUrl
),
nil
default
:
default
:
}
}
}
}
...
...
relay/channel/volcengine/tts.go
View file @
1be4e12c
...
@@ -37,13 +37,40 @@ type VolcengineTTSAudio struct {
...
@@ -37,13 +37,40 @@ type VolcengineTTSAudio struct {
Encoding
string
`json:"encoding"`
Encoding
string
`json:"encoding"`
SpeedRatio
float64
`json:"speed_ratio"`
SpeedRatio
float64
`json:"speed_ratio"`
Rate
int
`json:"rate"`
Rate
int
`json:"rate"`
Bitrate
int
`json:"bitrate,omitempty"`
LoudnessRatio
float64
`json:"loudness_ratio,omitempty"`
LoudnessRatio
float64
`json:"loudness_ratio,omitempty"`
EnableEmotion
bool
`json:"enable_emotion,omitempty"`
Emotion
string
`json:"emotion,omitempty"`
EmotionScale
float64
`json:"emotion_scale,omitempty"`
ExplicitLanguage
string
`json:"explicit_language,omitempty"`
ContextLanguage
string
`json:"context_language,omitempty"`
}
}
type
VolcengineTTSReqInfo
struct
{
type
VolcengineTTSReqInfo
struct
{
ReqID
string
`json:"reqid"`
ReqID
string
`json:"reqid"`
Text
string
`json:"text"`
Text
string
`json:"text"`
Operation
string
`json:"operation"`
Operation
string
`json:"operation"`
Model
string
`json:"model,omitempty"`
TextType
string
`json:"text_type,omitempty"`
SilenceDuration
float64
`json:"silence_duration,omitempty"`
WithTimestamp
interface
{}
`json:"with_timestamp,omitempty"`
ExtraParam
*
VolcengineTTSExtraParam
`json:"extra_param,omitempty"`
}
type
VolcengineTTSExtraParam
struct
{
DisableMarkdownFilter
bool
`json:"disable_markdown_filter,omitempty"`
EnableLatexTn
bool
`json:"enable_latex_tn,omitempty"`
MuteCutThreshold
string
`json:"mute_cut_threshold,omitempty"`
MuteCutRemainMs
string
`json:"mute_cut_remain_ms,omitempty"`
DisableEmojiFilter
bool
`json:"disable_emoji_filter,omitempty"`
UnsupportedCharRatioThresh
float64
`json:"unsupported_char_ratio_thresh,omitempty"`
AigcWatermark
bool
`json:"aigc_watermark,omitempty"`
CacheConfig
*
VolcengineTTSCacheConfig
`json:"cache_config,omitempty"`
}
type
VolcengineTTSCacheConfig
struct
{
TextType
int
`json:"text_type,omitempty"`
UseCache
bool
`json:"use_cache,omitempty"`
}
}
type
VolcengineTTSResponse
struct
{
type
VolcengineTTSResponse
struct
{
...
@@ -89,7 +116,7 @@ func mapVoiceType(openAIVoice string) string {
...
@@ -89,7 +116,7 @@ func mapVoiceType(openAIVoice string) string {
if
voice
,
ok
:=
openAIToVolcengineVoiceMap
[
openAIVoice
];
ok
{
if
voice
,
ok
:=
openAIToVolcengineVoiceMap
[
openAIVoice
];
ok
{
return
voice
return
voice
}
}
return
"zh_male_M392_conversation_wvae_bigtts"
return
openAIVoice
}
}
func
mapSpeedRatio
(
speed
float64
)
float64
{
func
mapSpeedRatio
(
speed
float64
)
float64
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment