tts

package
v0.0.0-...-e40a8b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2019 License: MIT Imports: 20 Imported by: 1

README

Telestream Cloud Timed Text Speech Go SDK

This library provides a low-level interface to the REST API of Telestream Cloud, the online video encoding service.

Getting Started

Initialize client
config := tts.NewConfiguration()
client := tts.NewAPIClient(config)

Authorization
ctx := context.Background()
ctx = context.WithValue(ctx, tts.ContextAPIKey, tts.APIKey{Key: "YOUR_API_KEY"})
client.Service.Operation(ctx, args)
Create project
project, _, err := client.TtsApi.CreateProject(ctx, tts.Project{Name: "Example project from Go"})

if err != nil {
    log.Fatal(err)
}
fmt.Println(project)
Create job from URL
projectID := "YOUR_PROJECT_ID"
job, _, err := client.TtsApi.CreateJob(ctx, projectID, tts.Job{SourceUrl: "http://url/to/file.mp4"})
if err != nil {
    log.Fatal(err)
}
fmt.Println(job)
Create job from File
projectID := "YOUR_PROJECT_ID"

upload, err := uploader.New(client.TtsApi, projectID)
if err != nil {
    log.Fatal(err)
}

file, err := os.Open("/path/to/local/file.mp4")
if err != nil {
    log.Fatal(err)
}
defer file.Close()

fileInfo, err := file.Stat()
if err != nil {
    log.Fatal(err)
}

if err := upload.Upload(ctx, file, file.Name(), fileInfo.Size(), "", nil); err != nil {
    log.Fatal(err)
}

fmt.Printf("Created job: %s\n", upload.MediaID)

Overview

This API client was generated by the swagger-codegen project. By using the swagger-spec from a remote server, you can easily generate an API client.

  • API version: 2.0.0
  • Package version: 2.0.1
  • Build package: io.swagger.codegen.languages.GoClientCodegen

Documentation for API Endpoints

All URIs are relative to https://api.cloud.telestream.net/tts/v1.0

Class Method HTTP request Description
TtsApi Corpora Get /projects/{projectID}/corpora Returns a collection of Corpora
TtsApi Corpus Get /projects/{projectID}/corpora/{name} Returns the Corpus
TtsApi CreateCorpus Post /projects/{projectID}/corpora/{name} Creates a new Corpus
TtsApi CreateJob Post /projects/{projectID}/jobs Creates a new Job
TtsApi CreateProject Post /projects Creates a new Project
TtsApi DeleteCorpus Delete /projects/{projectID}/corpora/{name} Creates a new Corpus
TtsApi DeleteJob Delete /projects/{projectID}/jobs/{jobID} Deletes the Job
TtsApi DeleteProject Delete /projects/{projectID} Deletes the Project
TtsApi Job Get /projects/{projectID}/jobs/{jobID} Returns the Job
TtsApi JobOutputs Get /projects/{projectID}/jobs/{jobID}/outputs Returns the Job Outputs
TtsApi JobResult Get /projects/{projectID}/jobs/{jobID}/result Returns the Job Result
TtsApi Jobs Get /projects/{projectID}/jobs Returns a collection of Jobs
TtsApi Project Get /projects/{projectID} Returns the Project
TtsApi Projects Get /projects Returns a collection of Projects
TtsApi TrainProject Post /projects/{projectID}/train Queues training
TtsApi UpdateProject Put /projects/{projectID} Updates an existing Project
TtsApi UploadVideo Post /projects/{projectID}/jobs/upload Creates an upload session

Documentation For Models

Documentation For Authorization

api_key

  • Type: API key

Example

	auth := context.WithValue(context.Background(), sw.ContextAPIKey, sw.APIKey{
		Key: "APIKEY",
		Prefix: "Bearer", // Omit if not necessary.
	})
    r, err := client.Service.Operation(auth, args)

Author

cloudsupport@telestream.net

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes a oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {

	// API Services
	TtsApi *TtsApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the Tts API API v2.0.0 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

Change base path to allow switching to mocks

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the swagger operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	HTTPClient    *http.Client
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

type CorporaCollection

type CorporaCollection struct {

	// An array of Corpus files
	Corpora []Corpus `json:"corpora,omitempty"`
}

type Corpus

type Corpus struct {

	// The name of the Corpus.
	Name string `json:"name,omitempty"`

	// Determines the status of the Corpus.
	Status string `json:"status,omitempty"`
}

type ErrorResponse

type ErrorResponse struct {
}

ErrorResponse

type ExtraFile

type ExtraFile struct {
	Tag string `json:"tag"`

	FileSize int64 `json:"file_size"`

	FileName string `json:"file_name"`
}

type Fragment

type Fragment struct {

	// The start time in seconds of the fragment from the input audio
	StartTime float32 `json:"start_time,omitempty"`

	// An array of FragmentVariants
	Variants []FragmentVariant `json:"variants,omitempty"`

	// The end time in seconds of the fragment from the input audio
	EndTime float32 `json:"end_time,omitempty"`
}

type FragmentVariant

type FragmentVariant struct {

	// An alternative hypothesis for a fragment from the input audio.
	Fragment string `json:"fragment,omitempty"`

	// The confidence score of the fragment variant hypothesis in the range of 0 to 1.
	Confidence float32 `json:"confidence,omitempty"`
}

type Job

type Job struct {

	// The ID of the job.
	Id string `json:"id,omitempty"`

	// The name of the job.
	Name string `json:"name,omitempty"`

	// The name of the input file
	OriginalFilename string `json:"original_filename,omitempty"`

	// The ID of the project.
	ProjectId string `json:"project_id,omitempty"`

	// The URL of source file.
	SourceUrl string `json:"source_url,omitempty"`

	// Determines the state of transcription job.
	Status string `json:"status,omitempty"`

	// If the status of the job is 'error', returns the state of job.
	Error_ string `json:"error,omitempty"`

	// A percentage that indicates the progress of the job.
	Progress int32 `json:"progress,omitempty"`

	// The confidence score of the job in the range of 0 to 100.
	Confidence int32 `json:"confidence,omitempty"`

	// The duration of the input audio in milliseconds.
	Duration int32 `json:"duration,omitempty"`

	// The bitrate of the input audio.
	Bitrate int32 `json:"bitrate,omitempty"`

	// The sample rate of the input audio.
	SampleRate int32 `json:"sample_rate,omitempty"`

	// The format of the input audio.
	Format string `json:"format,omitempty"`

	// The file size of the input file.
	FileSize int64 `json:"file_size,omitempty"`

	// Words used for model training, separated by space.
	CustomWords string `json:"custom_words,omitempty"`

	// A date and time when the job was created
	CreatedAt string `json:"created_at,omitempty"`

	// A date and time when the job was updated
	UpdatedAt string `json:"updated_at,omitempty"`
}

type JobOutput

type JobOutput struct {

	// Output file format
	Format string `json:"format,omitempty"`

	// URL to output (must be accessed with X-Api-Key)
	Url string `json:"url,omitempty"`
}

type JobResult

type JobResult struct {

	// An array of Results
	Results []Result `json:"results,omitempty"`
}

type JobsCollection

type JobsCollection struct {
	Jobs []Job `json:"jobs,omitempty"`

	// A number of the fetched page.
	Page int32 `json:"page,omitempty"`

	// A number of jobs per page.
	PerPage int32 `json:"per_page,omitempty"`

	// A number of pages.
	PageCount int32 `json:"page_count,omitempty"`

	// A number of all jobs.
	TotalCount int32 `json:"total_count,omitempty"`
}

type Project

type Project struct {

	// The ID of the Project.
	Id string `json:"id,omitempty"`

	// The name of the Project.
	Name string `json:"name,omitempty"`

	// The description of the Project.
	Description string `json:"description,omitempty"`

	// Determines a stage of training.
	Status string `json:"status,omitempty"`

	// The language code of model.
	Language string `json:"language,omitempty"`

	// The sample rate of model.
	SampleRate int32 `json:"sample_rate,omitempty"`

	// If true, the service replaces profanity from output with asterisks.
	ProfanityFilter bool `json:"profanity_filter,omitempty"`

	// Indicates whether video preview should be generated.
	GenerateProxy bool `json:"generate_proxy,omitempty"`

	// Words used for model training, separated by space.
	CustomWords string `json:"custom_words,omitempty"`

	Capabilities []string `json:"capabilities,omitempty"`

	// A date and time when the project was created
	CreatedAt string `json:"created_at,omitempty"`

	// A date and time when the project was updated
	UpdatedAt string `json:"updated_at,omitempty"`
}

type ProjectsCollection

type ProjectsCollection struct {
	Projects []Project `json:"projects,omitempty"`

	// A number of the fetched page.
	Page int32 `json:"page,omitempty"`

	// A number of projects per page.
	PerPage int32 `json:"per_page,omitempty"`

	// A number of pages.
	PageCount int32 `json:"page_count,omitempty"`

	// A number of all projects.
	TotalCount int32 `json:"total_count,omitempty"`
}

type Result

type Result struct {
	Transcript string `json:"transcript,omitempty"`

	// The start time in seconds of the transcript from the input audio
	StartTime float32 `json:"start_time,omitempty"`

	// An array of Fragments
	Fragments []Fragment `json:"fragments,omitempty"`

	// The end time time in seconds of the transcript from the input audio
	EndTime float32 `json:"end_time,omitempty"`

	// The confidence score of the result in the range of 0 to 1
	Confidence float32 `json:"confidence,omitempty"`
}

type TtsApiService

type TtsApiService service

func (*TtsApiService) Corpora

func (a *TtsApiService) Corpora(ctx context.Context, projectID string) (CorporaCollection, *http.Response, error)

TtsApiService Returns a collection of Corpora Returns a collection of Corpora * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @return CorporaCollection

func (*TtsApiService) Corpus

func (a *TtsApiService) Corpus(ctx context.Context, projectID string, name string) (Corpus, *http.Response, error)

TtsApiService Returns the Corpus Returns the Corpus * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param name Corpus name @return Corpus

func (*TtsApiService) CreateCorpus

func (a *TtsApiService) CreateCorpus(ctx context.Context, projectID string, name string, body string) (*http.Response, error)

TtsApiService Creates a new Corpus Creates a new Corpus * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param name Corpus name @param body @return

func (*TtsApiService) CreateJob

func (a *TtsApiService) CreateJob(ctx context.Context, projectID string, job Job) (Job, *http.Response, error)

TtsApiService Creates a new Job Creates a new Job * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param job @return Job

func (*TtsApiService) CreateProject

func (a *TtsApiService) CreateProject(ctx context.Context, project Project) (Project, *http.Response, error)

TtsApiService Creates a new Project Creates a new Project * @param ctx context.Context for authentication, logging, tracing, etc. @param project @return Project

func (*TtsApiService) DeleteCorpus

func (a *TtsApiService) DeleteCorpus(ctx context.Context, projectID string, name string) (*http.Response, error)

TtsApiService Creates a new Corpus Creates a new Corpus * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param name Corpus name @return

func (*TtsApiService) DeleteJob

func (a *TtsApiService) DeleteJob(ctx context.Context, projectID string, jobID string) (*http.Response, error)

TtsApiService Deletes the Job Deletes the Job * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param jobID @return

func (*TtsApiService) DeleteProject

func (a *TtsApiService) DeleteProject(ctx context.Context, projectID string) (*http.Response, error)

TtsApiService Deletes the Project Deletes the Project * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @return

func (*TtsApiService) Job

func (a *TtsApiService) Job(ctx context.Context, projectID string, jobID string) (Job, *http.Response, error)

TtsApiService Returns the Job Returns the Job * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param jobID @return Job

func (*TtsApiService) JobOutputs

func (a *TtsApiService) JobOutputs(ctx context.Context, projectID string, jobID string) ([]JobOutput, *http.Response, error)

TtsApiService Returns the Job Outputs Returns the Job Outputs * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param jobID @return []JobOutput

func (*TtsApiService) JobResult

func (a *TtsApiService) JobResult(ctx context.Context, projectID string, jobID string) (JobResult, *http.Response, error)

TtsApiService Returns the Job Result Returns the Job Result * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param jobID @return JobResult

func (*TtsApiService) Jobs

func (a *TtsApiService) Jobs(ctx context.Context, projectID string, localVarOptionals map[string]interface{}) (JobsCollection, *http.Response, error)

TtsApiService Returns a collection of Jobs Returns a collection of Jobs * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param optional (nil or map[string]interface{}) with one or more of:

@param "page" (int32) page number
@param "perPage" (int32) number of records per page

@return JobsCollection

func (*TtsApiService) Project

func (a *TtsApiService) Project(ctx context.Context, projectID string) (Project, *http.Response, error)

TtsApiService Returns the Project Returns the Project * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @return Project

func (*TtsApiService) Projects

TtsApiService Returns a collection of Projects Returns a collection of Projects * @param ctx context.Context for authentication, logging, tracing, etc. @return ProjectsCollection

func (*TtsApiService) TrainProject

func (a *TtsApiService) TrainProject(ctx context.Context, projectID string) (*http.Response, error)

TtsApiService Queues training Queues training * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @return

func (*TtsApiService) UpdateProject

func (a *TtsApiService) UpdateProject(ctx context.Context, projectID string, project Project) (Project, *http.Response, error)

TtsApiService Updates an existing Project Updates an existing Project * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param project @return Project

func (*TtsApiService) UploadVideo

func (a *TtsApiService) UploadVideo(ctx context.Context, projectID string, videoUploadBody VideoUploadBody) (UploadSession, *http.Response, error)

TtsApiService Creates an upload session * @param ctx context.Context for authentication, logging, tracing, etc. @param projectID ID of the Project @param videoUploadBody @return UploadSession

type UploadSession

type UploadSession struct {

	// An unique identifier of the UploadSession.
	Id string `json:"id"`

	// An URL to which chunks of the uploaded file should be sent
	Location string `json:"location"`

	// A number of chunks that are expected by the upstream.
	Parts int32 `json:"parts,string,omitempty"`

	// An expected size of uploaded chunks.
	PartSize int32 `json:"part_size,string,omitempty"`

	// A maximum number of concurrent connections.
	MaxConnections int32 `json:"max_connections,string,omitempty"`

	// An object containing additional files uploaded using the session.
	ExtraFiles *interface{} `json:"extra_files,omitempty"`
}

type VideoUploadBody

type VideoUploadBody struct {

	// Size of the file that will be uploaded in `bytes`.
	FileSize int64 `json:"file_size"`

	// Name of the file that will be uploaded.
	FileName string `json:"file_name"`

	Profiles string `json:"profiles,omitempty"`

	MultiChunk bool `json:"multi_chunk,omitempty"`

	// A list of names of additional files that will be uploaded.
	ExtraFiles []ExtraFile `json:"extra_files,omitempty"`

	Job *Job `json:"job,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL