项目作者: threeaccents

项目描述 :
Rev.ai golang client
高级语言: Go
项目地址: git://github.com/threeaccents/revai-go.git
创建时间: 2020-04-28T02:26:23Z
项目社区:https://github.com/threeaccents/revai-go

开源协议:MIT License

下载


Go Rev.ai

Go Report Card
GoDoc

A Rev.ai Go client library.

Installation

Install revai-go with:

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

Then, import it using:

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

Documentation

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

Below are a few simple examples:

New Client

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

New Client With Options

  1. httpClient := &http.Client{
  2. Timeout: 30 * time.Second,
  3. }
  4. c := revai.NewClient(
  5. "API_KEY",
  6. revai.HTTPClient(httpClient),
  7. revai.UserAgent("my-user-agent"),
  8. )

Submit Local File Job

  1. params := &revai.NewFileJobParams{
  2. Media: f, // some io.Reader
  3. Filename: f.Name(),
  4. }
  5. ctx := context.Background()
  6. job, err := c.Job.SubmitFile(ctx, params)
  7. // handle err
  8. fmt.Println("status", job.Status)

Submit Url Job

  1. const mediaURL = "https://support.rev.com/hc/en-us/article_attachments/200043975/FTC_Sample_1_-_Single.mp3"
  2. params := &revai.NewURLJobParams{
  3. MediaURL: mediaURL,
  4. }
  5. ctx := context.Background()
  6. job, err := c.Job.SubmitURL(ctx, params)
  7. // handle err
  8. fmt.Println("status", job.Status)

Caption

  1. params := &revai.GetCaptionParams{
  2. JobID: "job-id"
  3. }
  4. ctx := context.Background()
  5. caption, err := c.Caption.Get(ctx, params)
  6. // error check
  7. fmt.Println("srt caption", caption.Value)

Account

  1. ctx := context.Background()
  2. account, err := c.Account.Get(ctx)
  3. // error check
  4. fmt.Println("balance", account.BalanceSeconds)

Stream

streaming example