cerevoicego

package module
v0.0.0-...-2e4ca8e Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2019 License: BSD-2-Clause Imports: 4 Imported by: 0

README

CereVoice Go

CereVoice Go is a Go package for accessing the CereProc CereVoice Cloud API. Currently this package implements all available functions using the REST API. SOAP has not yet been implemented.

Notice

Please note that is package is not complete and is considered pre-release, meaning it is subject to change. Safety not guaranteed.

Usage

Assuming you have Go already setup and working, grab the latest version of the package from master.

go get github.com/bganderson/cerevoicego

Import the package into your project.

import "github.com/bganderson/cerevoicego"

Create a cerevoice client. Please note that AccountID and Password are not the same credentials you use to login to the website.

For the REST API URL you can use the exported const provided by the package.

cerevoice := cerevoicego.Client{
    CereVoiceAPIURL: cerevoicego.DefaultRESTAPIURL,
    AccountID:       "<YOUR_ACCOUNTID>",
    Password:        "<YOUR_PASSWORD",
}

Make an API request and do something with the response.

res := cerevoice.SpeakSimple(&cerevoicego.SpeakSimpleInput{
    Voice: "Jess",
    Text:  "Hello world!",
})
if res.Error != nil {
    log.Fatalln(res.Error)
}

fmt.Printf("The sound file is available at: %s\n", res.FileURL)

Documentation

Index

Constants

View Source
const (
	// VERSION is the global package version
	VERSION = "0.3.0"
	// DefaultRESTAPIURL is the default CereVoice Cloud REST API endpoint
	DefaultRESTAPIURL = "https://cerevoice.com/rest/rest_1_1.php"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Abbreviation

type Abbreviation struct {
	URL          string `xml:"url"`
	Language     string `xml:"language"`
	LastModified string `xml:"lastModified"`
	Size         string `xml:"size"`
}

Abbreviation contains details about an abbreviation

type Client

type Client struct {
	AccountID       string // CereVoice Cloud API AccountID
	Password        string // CereVoice Cloud API Password
	CereVoiceAPIURL string // CereVoice Cloud API URL
}

Client API connection settings

func (*Client) GetCredit

func (c *Client) GetCredit() (r *GetCreditResponse)

GetCredit retrieves the credit information for the given account

func (*Client) ListAbbreviations

func (c *Client) ListAbbreviations() (r *ListAbbreviationsResponse)

ListAbbreviations lists custom abbreviation file(s)

func (*Client) ListAudioFormats

func (c *Client) ListAudioFormats() (r *ListAudioFormatsResponse)

ListAudioFormats lists the available audio encoding formats

func (*Client) ListLexicons

func (c *Client) ListLexicons() (r *ListLexiconsResponse)

ListLexicons lists custom lexicon file(s)

func (*Client) ListVoices

func (c *Client) ListVoices() (r *ListVoicesResponse)

ListVoices outputs information about the available voices

func (*Client) SpeakExtended

func (c *Client) SpeakExtended(input *SpeakExtendedInput) (r *SpeakExtendedResponse)

SpeakExtended allows for more control over the audio output

func (*Client) SpeakSimple

func (c *Client) SpeakSimple(input *SpeakSimpleInput) (r *SpeakSimpleResponse)

SpeakSimple synthesises input text with the selected voice

func (*Client) UploadAbbreviations

func (c *Client) UploadAbbreviations(input *UploadAbbreviationsInput) (r *UploadAbbreviationsResponse)

UploadAbbreviations uploads and stores a custom abbreviation file

func (*Client) UploadLexicon

func (c *Client) UploadLexicon(input *UploadLexiconInput) (r *UploadLexiconResponse)

UploadLexicon uploads and stores a custom lexicon file

type Credit

type Credit struct {
	FreeCredit     string `xml:"freeCredit"`
	PaidCredit     string `xml:"paidCredit"`
	CharsAvailable string `xml:"charsAvailable"`
}

Credit contains details about CereVoice Cloud credits

type GetCreditResponse

type GetCreditResponse struct {
	Credit Credit `xml:"credit"`
	Error  error
}

GetCreditResponse contains response from getCredit

type Lexicon

type Lexicon struct {
	URL          string `xml:"url"`
	Language     string `xml:"language"`
	Accent       string `xml:"accent"`
	LastModified string `xml:"lastModified"`
	Size         string `xml:"size"`
}

Lexicon contains details about a lexicon

type ListAbbreviationsResponse

type ListAbbreviationsResponse struct {
	AbbreviationList []Abbreviation `xml:"abbreviationList>abbreviationFile"`
	Error            error
}

ListAbbreviationsResponse contains response from listAbbreviations

type ListAudioFormatsResponse

type ListAudioFormatsResponse struct {
	AudioFormats []string `xml:"formatList>format"`
	Error        error
}

ListAudioFormatsResponse contains response from listAudioFormats

type ListLexiconsResponse

type ListLexiconsResponse struct {
	LexiconList []Lexicon `xml:"lexiconList>lexiconFile"`
	Error       error
}

ListLexiconsResponse contains response from listLexicons

type ListVoicesResponse

type ListVoicesResponse struct {
	VoiceList []Voice `xml:"voicesList>voice"`
	Error     error
}

ListVoicesResponse contains response from listVoices

type Request

type Request struct {
	XMLName          xml.Name
	AccountID        string `xml:"accountID"`
	Password         string `xml:"password"`
	Voice            string `xml:"voice,omitempty"`
	Text             string `xml:"text,omitempty"`
	AudioFormat      string `xml:"audioFormat,omitempty"`
	SampleRate       string `xml:"sampleRate,omitempty"`
	Audio3D          bool   `xml:"audio3D,omitempty"`
	Metadata         bool   `xml:"metadata,omitempty"`
	LexiconFile      string `xml:"lexiconFile,omitempty"`
	AbbreviationFile string `xml:"abbreviationFile,omitempty"`
	Language         string `xml:"language,omitempty"`
	Accent           string `xml:"accent,omitempty"`
}

Request to CereVoice Cloud API

type Response

type Response struct {
	Raw   []byte
	Error error
}

Response from CereVoice Cloud API

type SpeakExtendedInput

type SpeakExtendedInput struct {
	Voice       string
	Text        string
	AudioFormat string
	SampleRate  string
	Audio3D     bool
	Metadata    bool
}

SpeakExtendedInput contains speakExtended parameters

type SpeakExtendedResponse

type SpeakExtendedResponse struct {
	FileURL           string `xml:"fileUrl"`
	CharCount         string `xml:"charCount"`
	ResultCode        string `xml:"resultCode"`
	ResultDescription string `xml:"resultDescription"`
	Metadata          string `xml:"metadataUrl"`
	Error             error
}

SpeakExtendedResponse contains response from speakExtended

type SpeakSimpleInput

type SpeakSimpleInput struct {
	Voice string
	Text  string
}

SpeakSimpleInput contains speakSimple parameters

type SpeakSimpleResponse

type SpeakSimpleResponse struct {
	FileURL           string `xml:"fileUrl"`
	CharCount         string `xml:"charCount"`
	ResultCode        string `xml:"resultCode"`
	ResultDescription string `xml:"resultDescription"`
	Error             error
}

SpeakSimpleResponse contains response from speakSimple

type UploadAbbreviationsInput

type UploadAbbreviationsInput struct {
	AbbreviationFile string
	Language         string
}

UploadAbbreviationsInput contains uploadAbbreviations parameters

type UploadAbbreviationsResponse

type UploadAbbreviationsResponse struct {
	ResultCode        int    `xml:"resultCode"`
	ResultDescription string `xml:"resultDescription"`
	Error             error
}

UploadAbbreviationsResponse contains response from uploadAbbreviations

type UploadLexiconInput

type UploadLexiconInput struct {
	LexiconFile string
	Language    string
	Accent      string
}

UploadLexiconInput contains uploadLexicon paramters

type UploadLexiconResponse

type UploadLexiconResponse struct {
	ResultCode        int    `xml:"resultCode"`
	ResultDescription string `xml:"resultDescription"`
	Error             error
}

UploadLexiconResponse contains response from uploadLexicon

type Voice

type Voice struct {
	SampleRate            string `xml:"sampleRate"`
	VoiceName             string `xml:"voiceName"`
	LanguageCodeISO       string `xml:"languageCodeISO"`
	CountryCodeISO        string `xml:"countryCodeISO"`
	AccentCode            string `xml:"accentCode"`
	Sex                   string `xml:"sex"`
	LanguageCodeMicrosoft string `xml:"languageCodeMicrosoft"`
	Country               string `xml:"country"`
	Region                string `xml:"region"`
	Accent                string `xml:"accent"`
}

Voice contains details about a voice

Jump to

Keyboard shortcuts

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