kai5263499 / captionbot

Simple Go API wrapper for https://www.captionbot.ai/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

captionbot

Captionbot is a simple API wrapper for https://www.captionbot.ai/

Installation

go get github.com/nhatbui/captionbot

Usage

package main

import (
	"fmt"
	"github.com/nhatbui/captionbot"
	"os"
)

var (
    bot *captionbot.CaptionBot
    caption string
    err error
)

func main() {
	bot, err = captionbot.New()
	if err != nil {
        fmt.Errorf("error instantiating bot %s", err)
        os.Exit(-1)
    }

	imgURL := "http://www.nhatqbui.com/assets/me.jpg"

	caption, err = bot.URLCaption(imgURL)
    if err != nil {
        fmt.Errorf("error uploading caption %s", err)
        os.Exit(-1)
    }
    fmt.Println(caption)

    // Or upload it

    imgFile := "/path/to/image.jpg"
    caption, err = bot.UploadCaption(imgFile)
    if err != nil {
        fmt.Errorf("error uploading caption %s", err)
        os.Exit(-1)
    }
    fmt.Println(caption)
}

Thanks

Thanks to @krikunts for their work on captionbot in Python that inspired this package.

About

Simple Go API wrapper for https://www.captionbot.ai/

License:MIT License


Languages

Language:Go 100.0%