迁移音频生成与语音合成到 gateway 并补充 simulation 测试
This commit is contained in:
@@ -84,6 +84,66 @@ func TestVideoBillingEstimateUsesFiveSecondUnitsAndDynamicWeights(t *testing.T)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMusicBillingUsesSongResourceAndOutputCount(t *testing.T) {
|
||||
service := &Service{}
|
||||
candidate := store.RuntimeModelCandidate{
|
||||
ModelName: "suno-model",
|
||||
BaseBillingConfig: map[string]any{
|
||||
"musicBase": 6,
|
||||
"music": map[string]any{"basePrice": 9},
|
||||
},
|
||||
}
|
||||
|
||||
items := service.billings(context.Background(), nil, "song.generations", map[string]any{
|
||||
"prompt": "city lights",
|
||||
"count": 3,
|
||||
}, candidate, clients.Response{}, true)
|
||||
|
||||
line := firstBillingLine(t, items)
|
||||
if got, want := line["resourceType"], "music"; got != want {
|
||||
t.Fatalf("music resource type = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := line["unit"], "song"; got != want {
|
||||
t.Fatalf("music billing unit = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := line["quantity"], 3; got != want {
|
||||
t.Fatalf("music quantity = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := floatFromAny(line["amount"]), 18.0; got != want {
|
||||
t.Fatalf("music amount = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpeechBillingUsesAudioCharacters(t *testing.T) {
|
||||
service := &Service{}
|
||||
candidate := store.RuntimeModelCandidate{
|
||||
ModelName: "speech-model",
|
||||
BaseBillingConfig: map[string]any{
|
||||
"audioBase": 0.5,
|
||||
"audio": map[string]any{"basePrice": 0.8},
|
||||
},
|
||||
}
|
||||
|
||||
items := service.billings(context.Background(), nil, "speech.generations", map[string]any{
|
||||
"text": "你好abc",
|
||||
"voice_id": "female-shaonv",
|
||||
}, candidate, clients.Response{}, true)
|
||||
|
||||
line := firstBillingLine(t, items)
|
||||
if got, want := line["resourceType"], "audio"; got != want {
|
||||
t.Fatalf("speech resource type = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := line["unit"], "character"; got != want {
|
||||
t.Fatalf("speech billing unit = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := line["quantity"], 5; got != want {
|
||||
t.Fatalf("speech character quantity = %v, want %v", got, want)
|
||||
}
|
||||
if got, want := floatFromAny(line["amount"]), 2.5; got != want {
|
||||
t.Fatalf("speech amount = %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVideoBillingPrefersGeneratedDuration(t *testing.T) {
|
||||
service := &Service{}
|
||||
candidate := store.RuntimeModelCandidate{
|
||||
|
||||
Reference in New Issue
Block a user