From 019eb56bc18c71776bf72c2b3bbc430541cc69f9 Mon Sep 17 00:00:00 2001 From: igolaizola <11333576+igolaizola@users.noreply.github.com> Date: Mon, 31 Jul 2023 21:30:18 +0200 Subject: [PATCH] Allow generations with only text prompts --- cmd/vidai/main.go | 4 ++-- vidai.go | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/vidai/main.go b/cmd/vidai/main.go index c4fa252..84d65a3 100644 --- a/cmd/vidai/main.go +++ b/cmd/vidai/main.go @@ -110,8 +110,8 @@ func newGenerateCommand() *ffcli.Command { if cfg.Token == "" { return fmt.Errorf("token is required") } - if *image == "" { - return fmt.Errorf("image is required") + if *image == "" && *text == "" { + return fmt.Errorf("image or text is required") } c := vidai.New(&cfg) urls, err := c.Generate(ctx, *image, *text, *output, *extend, diff --git a/vidai.go b/vidai.go index 535a295..ac833dc 100644 --- a/vidai.go +++ b/vidai.go @@ -55,9 +55,12 @@ func (c *Client) Generate(ctx context.Context, image, text, output string, } name := filepath.Base(image) - imageURL, err := c.client.Upload(ctx, name, b) - if err != nil { - return nil, fmt.Errorf("vidai: couldn't upload image: %w", err) + var imageURL string + if image != "" { + imageURL, err = c.client.Upload(ctx, name, b) + if err != nil { + return nil, fmt.Errorf("vidai: couldn't upload image: %w", err) + } } videoURL, err := c.client.Generate(ctx, imageURL, text, interpolate, upscale, watermark) if err != nil {