Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ fmt.Println("status", job.Status)
const mediaURL = "https://support.rev.com/hc/en-us/article_attachments/200043975/FTC_Sample_1_-_Single.mp3"

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

ctx := context.Background()
Expand Down Expand Up @@ -107,3 +109,39 @@ fmt.Println("balance", account.BalanceSeconds)

### Stream
[streaming example](examples/streaming/stream.go)


### Submit Local LanguageId Job

```go
params := &revai.LanguageIdParams{
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 LanguageId Job

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

params := &revai.LanguageIdParams{
SourceConfig: &UrlConfig{
Url: mediaURL,
},
MetaData: "This is a test",
}

ctx := context.Background()

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

fmt.Println("status", job.Status)
```
2 changes: 1 addition & 1 deletion examples/streaming/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"time"

"github.com/oriiolabs/revai-go"
"github.com/threeaccents/revai-go/src/revai"
)

func main() {
Expand Down
80 changes: 0 additions & 80 deletions main_test.go

This file was deleted.

9 changes: 9 additions & 0 deletions src/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/threeaccents/revai-go/src/revai

go 1.14

require (
github.com/google/go-querystring v1.0.0
github.com/gorilla/websocket v1.4.2
github.com/stretchr/testify v1.5.1
)
15 changes: 15 additions & 0 deletions src/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
9 changes: 7 additions & 2 deletions account.go → src/revai/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@ type AccountService service

// Account is the developer's account information
type Account struct {
Email string `json:"email"`
BalanceSeconds int `json:"balance_seconds"`
Email string `json:"email"`
FreeBalance float64 `json:"free_balance"`
PurchasedBalance float64 `json:"purchased_balance"`
TotalBalance float64 `json:"total_balance"`
InvoicedBalance float64 `json:"invoiced_balance"`
BalanceSeconds int `json:"balance_seconds"`
HipaaEnabled bool `json:"hipaa_enabled"`
}

// Get the developer's account information
Expand Down
File renamed without changes.
12 changes: 9 additions & 3 deletions caption.go → src/revai/caption.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type Caption struct {
// GetCaptionParams specifies the parameters to the
// CaptionService.Get method.
type GetCaptionParams struct {
JobID string
Accept string
JobID string
Accept string
SpeakerChannel *int
}

// Get returns the caption output for a transcription job.
Expand All @@ -34,7 +35,12 @@ func (s *CaptionService) Get(ctx context.Context, params *GetCaptionParams) (*Ca
accept = XSubripHeader
}

req, err := s.client.newRequest(http.MethodGet, urlPath, nil)
var speakerChannel interface{}
if params.SpeakerChannel != nil {
speakerChannel = *params.SpeakerChannel
}

req, err := s.client.newRequest(http.MethodGet, urlPath, speakerChannel)
if err != nil {
return nil, fmt.Errorf("failed creating request %w", err)
}
Expand Down
File renamed without changes.
23 changes: 6 additions & 17 deletions custom_vocabulary.go → src/revai/custom_vocabulary.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ type CustomVocabulary struct {
// CreateCustomVocabularyParams specifies the parameters to the
// CustomVocabularyService.Create method.
type CreateCustomVocabularyParams struct {
CustomVocabularies []Phrase `json:"custom_vocabularies"`
Metadata string `json:"metadata,omitempty"`
CallbackURL string `json:"callback_url,omitempty"`
CustomVocabularies []Phrase `json:"custom_vocabularies"`
Metadata string `json:"metadata,omitempty"`
SourceConfig *UrlConfig `json:"source_config,omitempty"`
NotificationConfig *UrlConfig `json:"notification_config,omitempty"`
}

type Phrase struct {
Expand Down Expand Up @@ -76,15 +77,9 @@ func (s *CustomVocabularyService) Get(ctx context.Context, params *GetCustomVoca
return &vocabulary, nil
}

// ListCustomVocabularyParams specifies the parameters to the
// CustomVocabularyService.List method.
type ListCustomVocabularyParams struct {
Limit int `url:"limit,omitempty"`
}

// List gets a list of most recent custom vocabularies' processing information
// https://www.rev.ai/docs/streaming#operation/GetCustomVocabularies
func (s *CustomVocabularyService) List(ctx context.Context, params *ListCustomVocabularyParams) ([]*CustomVocabulary, error) {
func (s *CustomVocabularyService) List(ctx context.Context, params *ListParams) ([]*CustomVocabulary, error) {
urlPath := "/speechtotext/v1/vocabularies"

req, err := s.client.newRequest(http.MethodGet, urlPath, params)
Expand All @@ -100,15 +95,9 @@ func (s *CustomVocabularyService) List(ctx context.Context, params *ListCustomVo
return vocabularies, nil
}

// DeleteCustomVocabularyParams specifies the parameters to the
// CustomVocabularyService.Delete method.
type DeleteCustomVocabularyParams struct {
ID string
}

// Delete deletes the custom vocabulary.
// https://www.rev.ai/docs/streaming#operation/DeleteCustomVocabulary
func (s *CustomVocabularyService) Delete(ctx context.Context, params *DeleteCustomVocabularyParams) error {
func (s *CustomVocabularyService) Delete(ctx context.Context, params *DeleteParams) error {
urlPath := "/speechtotext/v1/vocabularies/" + params.ID

req, err := s.client.newRequest(http.MethodDelete, urlPath, nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestCustomVocabularyService_Get(t *testing.T) {
}

func TestCustomVocabularyService_List(t *testing.T) {
params := &ListCustomVocabularyParams{}
params := &ListParams{}

ctx := context.Background()

Expand All @@ -62,7 +62,7 @@ func TestCustomVocabularyService_List(t *testing.T) {
func TestCustomVocabularyService_Delete(t *testing.T) {
deletableVocab := makeTestVocab()

params := &DeleteCustomVocabularyParams{
params := &DeleteParams{
ID: deletableVocab.ID,
}

Expand Down
File renamed without changes.
40 changes: 40 additions & 0 deletions src/revai/generics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package revai

const (
LanguageIdJobType = "languageid"
SentimentAnalysisJobType = "sentiment_analysis"
TopicExtractionJobType = "topic_extraction"
)

// Config for Source/Notification Configs
// Same usage as MediaURL and CallbackURL
// Allow exactly map{"Authorization": "YOUR_AUTH_HERE"} as of 4/7/23
type UrlConfig struct {
Url string `json:"url,omitempty"`
AuthHeaders map[string]string `json:"auth_headers,omitempty"`
}

// ListParams specifies the optional query parameters to most List methods.
type ListParams struct {
Limit int `url:"limit,omitempty"`
StartingAfter string `url:"starting_after,omitempty"`
}

// The following are generic json structures sent through callback URL
// Use for unmarshalling request body
// https://docs.rev.ai/api/JOB_TYPE/webhooks/
// JOB_TYPE options are: asynchronous, topic-extraction, sentiment-analysis, language-identification, custom-vocabulary
type GenericPostJson struct {
Job *GenericJob `json:"job"`
CustomVocabularyJob *GenericJob `json:"custom_vocabulary"`
}

type GenericJob struct {
ID string `json:"id,omitempty"`
Created string `json:"created_on,omitempty"`
Completed string `json:"completed_on,omitempty"`
Metadata string `json:"metadata,omitempty"`
Status string `json:"status,omitempty"`
Duration float64 `json:"duration_seconds,omitempty"`
Type string `json:"type,omitempty"`
}
Loading