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
8ac80126
authored
Oct 18, 2025
by
IcedTangerine
Committed by
GitHub
Oct 18, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2068 from feitianbubu/pr/doubao-speech-emotion
豆包语音2.0音色支持情感,情绪,音量
parents
0d62db7c
13362887
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
20 deletions
+18
-20
dto/audio.go
+10
-5
relay/channel/volcengine/adaptor.go
+8
-1
relay/channel/volcengine/tts.go
+0
-14
No files found.
dto/audio.go
View file @
8ac80126
package
dto
import
(
"encoding/json"
"github.com/QuantumNous/new-api/types"
"github.com/gin-gonic/gin"
)
type
AudioRequest
struct
{
Model
string
`json:"model"`
Input
string
`json:"input"`
Voice
string
`json:"voice"`
Speed
float64
`json:"speed,omitempty"`
ResponseFormat
string
`json:"response_format,omitempty"`
Model
string
`json:"model"`
Input
string
`json:"input"`
Voice
string
`json:"voice"`
Instructions
string
`json:"instructions,omitempty"`
ResponseFormat
string
`json:"response_format,omitempty"`
Speed
float64
`json:"speed,omitempty"`
StreamFormat
string
`json:"stream_format,omitempty"`
Metadata
json
.
RawMessage
`json:"metadata,omitempty"`
}
func
(
r
*
AudioRequest
)
GetTokenCountMeta
()
*
types
.
TokenCountMeta
{
...
...
relay/channel/volcengine/adaptor.go
View file @
8ac80126
...
...
@@ -47,7 +47,7 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
}
voiceType
:=
mapVoiceType
(
request
.
Voice
)
speedRatio
:=
mapSpeedRatio
(
request
.
Speed
)
speedRatio
:=
request
.
Speed
encoding
:=
mapEncoding
(
request
.
ResponseFormat
)
c
.
Set
(
"response_format"
,
encoding
)
...
...
@@ -75,6 +75,13 @@ func (a *Adaptor) ConvertAudioRequest(c *gin.Context, info *relaycommon.RelayInf
},
}
// 同步扩展字段的厂商自定义metadata
if
len
(
request
.
Metadata
)
>
0
{
if
err
=
json
.
Unmarshal
(
request
.
Metadata
,
&
volcRequest
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error unmarshalling metadata to volcengine request: %w"
,
err
)
}
}
jsonData
,
err
:=
json
.
Marshal
(
volcRequest
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error marshalling volcengine request: %w"
,
err
)
...
...
relay/channel/volcengine/tts.go
View file @
8ac80126
...
...
@@ -119,20 +119,6 @@ func mapVoiceType(openAIVoice string) string {
return
openAIVoice
}
// [0.1,2],默认为 1,通常保留一位小数即可
func
mapSpeedRatio
(
speed
float64
)
float64
{
if
speed
==
0
{
return
1.0
}
if
speed
<
0.1
{
return
0.1
}
if
speed
>
2.0
{
return
2.0
}
return
speed
}
func
mapEncoding
(
responseFormat
string
)
string
{
if
encoding
,
ok
:=
responseFormatToEncodingMap
[
responseFormat
];
ok
{
return
encoding
...
...
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