Skip to content

revdotcom/revai-go

Repository files navigation

Go Rev.ai

Go Report Card GoDoc

A Rev.ai Go client library.

Installation

Install revai-go with:

go get -u github.com/threeaccents/revai-go

Then, import it using:

import (
    "github.com/threeaccents/revai-go"
)

Documentation

For details on all the functionality in this library, see the GoDoc documentation.

Below are a few simple examples:

New Client

// default client
c := revai.NewClient("API-KEY")

New Client With Options

httpClient := &http.Client{
    Timeout: 30 * time.Second,
}

c := revai.NewClient(
    "API_KEY",
    revai.HTTPClient(httpClient),
    revai.UserAgent("my-user-agent"),
)

Submit Local File Job

params := &revai.NewFileJobParams{
	Media:    f, // some io.Reader
	Filename: f.Name(),
}

ctx := context.Background()

job, err := c.Job.SubmitFile(ctx, params)
// handle err

fmt.Println("status", job.Status)

Submit Url Job

const mediaURL = "https://support.rev.com/hc/en-us/article_attachments/200043975/FTC_Sample_1_-_Single.mp3"

params := &revai.NewURLJobParams{
    MediaURL: mediaURL, 
}

ctx := context.Background()

job, err := c.Job.SubmitURL(ctx, params)
// handle err

fmt.Println("status", job.Status)

Caption

params := &revai.GetCaptionParams{
	JobID: "job-id"
}

ctx := context.Background()

caption, err := c.Caption.Get(ctx, params)
// error check

fmt.Println("srt caption", caption.Value)

Account

ctx := context.Background()

account, err := c.Account.Get(ctx)
// error check

fmt.Println("balance", account.BalanceSeconds)

Stream

streaming example