|
|
@@ -12,6 +12,7 @@ import (
|
|
|
"one-api/common"
|
|
|
"one-api/model"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
var availableVoices = []string{
|
|
|
@@ -24,12 +25,12 @@ var availableVoices = []string{
|
|
|
}
|
|
|
|
|
|
func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode {
|
|
|
-
|
|
|
tokenId := c.GetInt("token_id")
|
|
|
channelType := c.GetInt("channel")
|
|
|
channelId := c.GetInt("channel_id")
|
|
|
userId := c.GetInt("id")
|
|
|
group := c.GetString("group")
|
|
|
+ startTime := time.Now()
|
|
|
|
|
|
var audioRequest AudioRequest
|
|
|
if !strings.HasPrefix(c.Request.URL.Path, "/v1/audio/transcriptions") {
|
|
|
@@ -154,6 +155,7 @@ func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
|
|
|
|
|
|
defer func(ctx context.Context) {
|
|
|
go func() {
|
|
|
+ useTimeSeconds := time.Now().Unix() - startTime.Unix()
|
|
|
quota := 0
|
|
|
var promptTokens = 0
|
|
|
if strings.HasPrefix(audioRequest.Model, "tts-1") {
|
|
|
@@ -178,7 +180,7 @@ func relayAudioHelper(c *gin.Context, relayMode int) *OpenAIErrorWithStatusCode
|
|
|
if quota != 0 {
|
|
|
tokenName := c.GetString("token_name")
|
|
|
logContent := fmt.Sprintf("模型倍率 %.2f,分组倍率 %.2f", modelRatio, groupRatio)
|
|
|
- model.RecordConsumeLog(ctx, userId, channelId, promptTokens, 0, audioRequest.Model, tokenName, quota, logContent, tokenId, userQuota)
|
|
|
+ model.RecordConsumeLog(ctx, userId, channelId, promptTokens, 0, audioRequest.Model, tokenName, quota, logContent, tokenId, userQuota, int(useTimeSeconds), false)
|
|
|
model.UpdateUserUsedQuotaAndRequestCount(userId, quota)
|
|
|
channelId := c.GetInt("channel_id")
|
|
|
model.UpdateChannelUsedQuota(channelId, quota)
|