mirror of
https://github.com/linux-do/new-api.git
synced 2025-11-12 09:03:42 +08:00
support tts
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"one-api/common"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var stopFinishReason = "stop"
|
||||
@@ -106,6 +107,14 @@ func countTokenInput(input any, model string) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func countAudioToken(text string, model string) int {
|
||||
if strings.HasPrefix(model, "tts") {
|
||||
return utf8.RuneCountInString(text)
|
||||
} else {
|
||||
return countTokenText(text, model)
|
||||
}
|
||||
}
|
||||
|
||||
func countTokenText(text string, model string) int {
|
||||
tokenEncoder := getTokenEncoder(model)
|
||||
return getTokenNum(tokenEncoder, text)
|
||||
|
||||
Reference in New Issue
Block a user