迁移音频生成与语音合成到 gateway 并补充 simulation 测试
This commit is contained in:
@@ -112,6 +112,24 @@ func (s *Service) billings(ctx context.Context, user *auth.User, kind string, bo
|
||||
"durationUnitCount": durationUnits,
|
||||
})}
|
||||
}
|
||||
if kind == "song.generations" || kind == "music.generations" {
|
||||
resource = "music"
|
||||
unit = "song"
|
||||
baseKey = "musicBase"
|
||||
amount := float64(count) * resourcePrice(config, resource, baseKey, "basePrice") * discount
|
||||
return []any{billingLine(candidate, resource, unit, count, roundPrice(amount), discount, simulated)}
|
||||
}
|
||||
if kind == "speech.generations" {
|
||||
resource = "audio"
|
||||
unit = "character"
|
||||
baseKey = "audioBase"
|
||||
quantity := len([]rune(stringFromMap(body, "text")))
|
||||
if quantity <= 0 {
|
||||
quantity = 1
|
||||
}
|
||||
amount := float64(quantity) * resourcePrice(config, resource, baseKey, "basePrice") * discount
|
||||
return []any{billingLine(candidate, resource, unit, quantity, roundPrice(amount), discount, simulated)}
|
||||
}
|
||||
amount := float64(count) * resourcePrice(config, resource, baseKey, "basePrice") * resourceWeight(config, resource, "qualityWeights", stringFromMap(body, "quality")) * resourceWeight(config, resource, "sizeWeights", stringFromMap(body, "size")) * resourceWeight(config, resource, "resolutionWeights", firstNonEmptyString(stringFromMap(body, "resolution"), stringFromMap(body, "size"))) * discount
|
||||
return []any{billingLine(candidate, resource, unit, count, roundPrice(amount), discount, simulated)}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user