fix(canvas): 视频生成 - Seedance 视频请求正确传递声音开关
This commit is contained in:
1 parent
1aaa5a438e
commit
82d868ab0b
3 files changed
+41
-7
No files matched your search
@@ -1655,10 +1655,11 @@ func seedanceVideosBody(input canvasGenerationInput) (map[string]interface{}, er
|
|||||||
return nil, errors.New("Seedance 参考视频或参考音频需要同时连接至少 1 张主参考图")
|
return nil, errors.New("Seedance 参考视频或参考音频需要同时连接至少 1 张主参考图")
|
||||||
}
|
}
|
||||||
body := map[string]interface{}{
|
body := map[string]interface{}{
|
||||||
"model": input.Config.Model,
|
"model": input.Config.Model,
|
||||||
"prompt": seedanceVideosPromptText(input),
|
"prompt": seedanceVideosPromptText(input),
|
||||||
"aspect_ratio": normalizeSeedanceVideosRatio(input.Config.Size),
|
"aspect_ratio": normalizeSeedanceVideosRatio(input.Config.Size),
|
||||||
"duration": normalizeSeedanceVideosDuration(input.Config.VideoSeconds),
|
"duration": normalizeSeedanceVideosDuration(input.Config.VideoSeconds),
|
||||||
|
"generate_audio": parseBool(input.Config.VideoGenerateAudio, true),
|
||||||
}
|
}
|
||||||
imageURLs := make([]string, 0, len(input.ReferenceImages))
|
imageURLs := make([]string, 0, len(input.ReferenceImages))
|
||||||
for _, image := range input.ReferenceImages {
|
for _, image := range input.ReferenceImages {
|
||||||
|
|||||||
@@ -160,9 +160,10 @@ func TestSeedanceVideosBodyUsesVideosEndpointFields(t *testing.T) {
|
|||||||
body, err := seedanceVideosBody(canvasGenerationInput{
|
body, err := seedanceVideosBody(canvasGenerationInput{
|
||||||
Prompt: "make it move",
|
Prompt: "make it move",
|
||||||
Config: providerConfig{
|
Config: providerConfig{
|
||||||
Model: "seedance-2.0-mini-480p",
|
Model: "seedance-2.0-mini-480p",
|
||||||
Size: "9:16",
|
Size: "9:16",
|
||||||
VideoSeconds: "8",
|
VideoSeconds: "8",
|
||||||
|
VideoGenerateAudio: "true",
|
||||||
},
|
},
|
||||||
ReferenceImages: []providerMedia{
|
ReferenceImages: []providerMedia{
|
||||||
{ID: "image-1", DataURL: testReferenceImageDataURL},
|
{ID: "image-1", DataURL: testReferenceImageDataURL},
|
||||||
@@ -180,6 +181,9 @@ func TestSeedanceVideosBodyUsesVideosEndpointFields(t *testing.T) {
|
|||||||
if body["aspect_ratio"] != "9:16" || body["duration"] != 8 {
|
if body["aspect_ratio"] != "9:16" || body["duration"] != 8 {
|
||||||
t.Fatalf("size fields = %#v %#v", body["aspect_ratio"], body["duration"])
|
t.Fatalf("size fields = %#v %#v", body["aspect_ratio"], body["duration"])
|
||||||
}
|
}
|
||||||
|
if body["generate_audio"] != true {
|
||||||
|
t.Fatalf("generate_audio = %#v, want true", body["generate_audio"])
|
||||||
|
}
|
||||||
if body["image_url"] != testReferenceImageDataURL {
|
if body["image_url"] != testReferenceImageDataURL {
|
||||||
t.Fatalf("image_url = %#v", body["image_url"])
|
t.Fatalf("image_url = %#v", body["image_url"])
|
||||||
}
|
}
|
||||||
@@ -200,6 +204,34 @@ func TestSeedanceVideosBodyUsesVideosEndpointFields(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSeedanceVideosBodyHonorsGenerateAudio(t *testing.T) {
|
||||||
|
for _, test := range []struct {
|
||||||
|
name string
|
||||||
|
value string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{name: "default enabled", want: true},
|
||||||
|
{name: "explicit enabled", value: "true", want: true},
|
||||||
|
{name: "explicit disabled", value: "false", want: false},
|
||||||
|
} {
|
||||||
|
t.Run(test.name, func(t *testing.T) {
|
||||||
|
body, err := seedanceVideosBody(canvasGenerationInput{
|
||||||
|
Prompt: "make it move",
|
||||||
|
Config: providerConfig{
|
||||||
|
Model: "seedance-2.0-mini-480p",
|
||||||
|
VideoGenerateAudio: test.value,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("seedanceVideosBody() error = %v", err)
|
||||||
|
}
|
||||||
|
if body["generate_audio"] != test.want {
|
||||||
|
t.Fatalf("generate_audio = %#v, want %v", body["generate_audio"], test.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSeedanceVideosBodyUsesOrderedFrameImageURLsWhenConfigured(t *testing.T) {
|
func TestSeedanceVideosBodyUsesOrderedFrameImageURLsWhenConfigured(t *testing.T) {
|
||||||
body, err := seedanceVideosBody(canvasGenerationInput{
|
body, err := seedanceVideosBody(canvasGenerationInput{
|
||||||
Prompt: "make it move",
|
Prompt: "make it move",
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ async function buildSeedanceVideosPayload(config: AiConfig, model: string, promp
|
|||||||
prompt: buildSeedanceVideosPromptText(prompt, imageUrls.length, videoUrls.length, audioUrls.length),
|
prompt: buildSeedanceVideosPromptText(prompt, imageUrls.length, videoUrls.length, audioUrls.length),
|
||||||
aspect_ratio: ratio === "adaptive" ? "16:9" : ratio,
|
aspect_ratio: ratio === "adaptive" ? "16:9" : ratio,
|
||||||
duration: duration < 4 ? 5 : duration,
|
duration: duration < 4 ? 5 : duration,
|
||||||
|
generate_audio: boolConfig(config.videoGenerateAudio, true),
|
||||||
...(imageUrls[0] ? { image_url: imageUrls[0] } : {}),
|
...(imageUrls[0] ? { image_url: imageUrls[0] } : {}),
|
||||||
...(imageUrls.length > 1 ? { reference_image_urls: imageUrls.slice(1) } : {}),
|
...(imageUrls.length > 1 ? { reference_image_urls: imageUrls.slice(1) } : {}),
|
||||||
...(videoUrls.length ? { reference_videos: videoUrls } : {}),
|
...(videoUrls.length ? { reference_videos: videoUrls } : {}),
|
||||||
|
|||||||
Reference in new issue
Block a user