Skip to content

Commit

Permalink
added generate tts audio
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava committed May 2, 2023
1 parent 7ae64a3 commit eb96ca9
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions fakeyou/fakeyou.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type IFakeYou interface {
// voice api
GetListOfVoices() (*ResponseVoice, error)
GetListOfVoiceCategories() (*ResponseVoiceCategories, error)
GenerateTTSAudio(text string, ttsModelToken string) (*ResponseGenerateTTS, error)
// auth api
Login(body RequestLogin) error
}
Expand Down
6 changes: 6 additions & 0 deletions fakeyou/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ type RequestLogin struct {
Username string `json:"username_or_email" required:"true" validate:"nonnil,min=1"`
Password string `json:"password" required:"true" validate:"nonnil,min=4"`
}

type RequestGenerateTTS struct {
TTSModelToken string `json:"tts_model_token" required:"true" validate:"nonnil,min=4"`
UUIDIdempotencyToken string `json:"uuid_idempotency_token" required:"true" validate:"nonnil,min=4"`
InferenceText string `json:"inference_text" required:"true" validate:"nonnil,min=4"`
}
5 changes: 5 additions & 0 deletions fakeyou/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,8 @@ type ResponseVoiceCategories struct {
BaseResponse
Categories []Category `json:"categories"`
}

type ResponseGenerateTTS struct {
BaseResponse
InferenceJobToken string `json:"inference_job_token"`
}
34 changes: 34 additions & 0 deletions fakeyou/voice_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package fakeyou

import (
"encoding/json"
"fmt"

"gopkg.in/validator.v2"

"github.com/Allan-Nava/fakeyou.go/constants/routes"
)
Expand Down Expand Up @@ -42,3 +45,34 @@ func (f *fakeyou) GetListOfVoiceCategories() (*ResponseVoiceCategories, error) {
}
return &obj, nil
}

/*
Generate TTS Audio
Make a TTS request
To turn text into speech with your desired voice, you'll need to find the appropriate TTS model token from the model lookup API.
For example, TM:7wbtjphx8h8v in the following examples is our Mario * voice. (A paid voice actor that we hired to impersonate Mario).
*/

func (f *fakeyou) GenerateTTSAudio(text string, ttsModelToken string) (*ResponseGenerateTTS, error) {
//
body := &RequestGenerateTTS{
TTSModelToken: ttsModelToken,
InferenceText: text,
//UUIDIdempotencyToken: uuid,
}
if errs := validator.Validate(body); errs != nil {
// values not valid, deal with errors here
return nil, errs
}
//
resp, err := f.restyPost(routes.LOGIN, body)
if err != nil {
return nil, err
}
if resp.StatusCode() == 429 {
return nil, fmt.Errorf("IP IS BANNED (caused by login request)")
}
return nil, fmt.Errorf("")
}

0 comments on commit eb96ca9

Please sign in to comment.