Documentation
¶
Index ¶
- Variables
- type DescribeVoicesFilter
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) DeleteLexicon(name string) error
- func (b *InMemoryBackend) DescribeVoices(filter DescribeVoicesFilter) ([]Voice, error)
- func (b *InMemoryBackend) GetLexicon(name string) (*Lexicon, error)
- func (b *InMemoryBackend) GetSpeechSynthesisTask(taskID string) (*SpeechSynthesisTask, error)
- func (b *InMemoryBackend) ListLexicons() []*Lexicon
- func (b *InMemoryBackend) ListSpeechSynthesisTasks(status, token string, maxResults int) ([]*SpeechSynthesisTask, string, error)
- func (b *InMemoryBackend) ListTagsForResource(resourceArn string) ([]Tag, error)
- func (b *InMemoryBackend) PutLexicon(name, content string) error
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartSpeechSynthesisTask(options SynthesisOptions, outputBucket, roleArn, topicArn string) (*SpeechSynthesisTask, error)
- func (b *InMemoryBackend) SynthesizeSpeech(options SynthesisOptions) (*SynthesizedSpeech, error)
- func (b *InMemoryBackend) TagResource(resourceArn string, tags []Tag) error
- func (b *InMemoryBackend) TaskARN(taskID string) string
- func (b *InMemoryBackend) UntagResource(resourceArn string, keys []string) error
- type Lexicon
- type Provider
- type SpeechSynthesisTask
- type SynthesisOptions
- type SynthesizedSpeech
- type Tag
- type Voice
Constants ¶
This section is empty.
Variables ¶
var ( // ErrLexiconNotFound is returned when a requested lexicon is absent. ErrLexiconNotFound = errors.New("LexiconNotFoundException") // ErrTaskNotFound is returned when a requested synthesis task is absent. ErrTaskNotFound = errors.New("SynthesisTaskNotFoundException") // ErrValidation is returned when request parameters do not meet Polly constraints // that AWS models as a generic/unlisted validation failure. ErrValidation = errors.New("InvalidParameterValueException") // ErrResourceNotFound is returned when a tagged resource ARN is unknown. ErrResourceNotFound = errors.New("ResourceNotFoundException") // ErrTextLengthExceeded is returned when Text exceeds the format-specific length limit. ErrTextLengthExceeded = errors.New("TextLengthExceededException") // ErrInvalidSampleRate is returned when SampleRate is not valid for the requested OutputFormat. ErrInvalidSampleRate = errors.New("InvalidSampleRateException") // ErrEngineNotSupported is returned when the requested voice does not support the requested engine. ErrEngineNotSupported = errors.New("EngineNotSupportedException") // ErrLanguageNotSupported is returned when the requested voice does not support the requested language. ErrLanguageNotSupported = errors.New("LanguageNotSupportedException") // ErrMarksNotSupportedForFormat is returned when SpeechMarkTypes is requested with a non-json OutputFormat. ErrMarksNotSupportedForFormat = errors.New("MarksNotSupportedForFormatException") // ErrSsmlMarksNotSupportedForTextType is returned when the "ssml" speech mark type is // requested with a plain-text TextType. ErrSsmlMarksNotSupportedForTextType = errors.New("SsmlMarksNotSupportedForTextTypeException") // ErrInvalidNextToken is returned when a pagination token cannot be decoded. ErrInvalidNextToken = errors.New("InvalidNextTokenException") // ErrInvalidLexicon is returned when lexicon Content is not well-formed PLS lexicon XML. ErrInvalidLexicon = errors.New("InvalidLexiconException") )
Functions ¶
This section is empty.
Types ¶
type DescribeVoicesFilter ¶
type DescribeVoicesFilter struct {
Engine string
LanguageCode string
Gender string
IncludeAdditionalLanguageCodes bool
}
DescribeVoicesFilter limits voice responses.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
}
Handler implements Amazon Polly REST JSON operations.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates handler for backend.
func (*Handler) ChaosOperations ¶
ChaosOperations returns injectable operation list.
func (*Handler) ChaosRegions ¶
ChaosRegions returns backend region.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns service key.
func (*Handler) ExtractOperation ¶
ExtractOperation derives operation from request method and path.
func (*Handler) ExtractResource ¶
ExtractResource derives task ID, lexicon name, or ARN from request path.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns implemented SDK operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns request dispatcher.
func (*Handler) MatchPriority ¶
MatchPriority returns REST service routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches versioned Polly routes.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend stores Polly resources safely for concurrent requests.
lexicons and tasks are *store.Table[T]-backed (see store_setup.go and pkgs/store's package doc); tags remains a plain map since its values are map[string]string, not *T, so there is nothing for store.Table to key on. voices is the static built-in voice catalogue, not a mutable resource collection.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates a Polly backend configured for default AWS identity.
func NewInMemoryBackendWithConfig ¶
func NewInMemoryBackendWithConfig(accountID, region string) *InMemoryBackend
NewInMemoryBackendWithConfig creates a Polly backend configured for account and region.
func (*InMemoryBackend) DeleteLexicon ¶
func (b *InMemoryBackend) DeleteLexicon(name string) error
DeleteLexicon removes named lexicon.
func (*InMemoryBackend) DescribeVoices ¶
func (b *InMemoryBackend) DescribeVoices(filter DescribeVoicesFilter) ([]Voice, error)
DescribeVoices lists built-in voices matching filters.
func (*InMemoryBackend) GetLexicon ¶
func (b *InMemoryBackend) GetLexicon(name string) (*Lexicon, error)
GetLexicon returns named lexicon.
func (*InMemoryBackend) GetSpeechSynthesisTask ¶
func (b *InMemoryBackend) GetSpeechSynthesisTask(taskID string) (*SpeechSynthesisTask, error)
GetSpeechSynthesisTask retrieves task and advances simulated lifecycle.
func (*InMemoryBackend) ListLexicons ¶
func (b *InMemoryBackend) ListLexicons() []*Lexicon
ListLexicons lists lexicons ordered by name.
func (*InMemoryBackend) ListSpeechSynthesisTasks ¶
func (b *InMemoryBackend) ListSpeechSynthesisTasks( status, token string, maxResults int, ) ([]*SpeechSynthesisTask, string, error)
ListSpeechSynthesisTasks lists tasks and advances lifecycle consistently with AWS polling.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(resourceArn string) ([]Tag, error)
ListTagsForResource returns sorted task tags.
func (*InMemoryBackend) PutLexicon ¶
func (b *InMemoryBackend) PutLexicon(name, content string) error
PutLexicon creates or replaces lexicon content.
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns configured AWS region.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore deserializes backend state from a snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serializes the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) StartSpeechSynthesisTask ¶
func (b *InMemoryBackend) StartSpeechSynthesisTask( options SynthesisOptions, outputBucket, roleArn, topicArn string, ) (*SpeechSynthesisTask, error)
StartSpeechSynthesisTask creates scheduled asynchronous task.
func (*InMemoryBackend) SynthesizeSpeech ¶
func (b *InMemoryBackend) SynthesizeSpeech(options SynthesisOptions) (*SynthesizedSpeech, error)
SynthesizeSpeech validates options and returns deterministic audio or speech-mark output.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(resourceArn string, tags []Tag) error
TagResource adds tags to known task ARN.
func (*InMemoryBackend) TaskARN ¶
func (b *InMemoryBackend) TaskARN(taskID string) string
TaskARN returns resource ARN for tags on created task.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(resourceArn string, keys []string) error
UntagResource removes tag keys from known task ARN.
type Lexicon ¶
type Lexicon struct {
LastModified time.Time
Name string
ARN string
Content string
Alphabet string
LanguageCode string
LexemesCount int
Size int
}
Lexicon stores pronunciation content and computed lexicon attributes.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for Amazon Polly.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes Polly backend and REST handler.
type SpeechSynthesisTask ¶
type SpeechSynthesisTask struct {
CreationTime time.Time
TaskID string
TaskStatus string
TaskStatusReason string
OutputURI string
OutputS3BucketName string
SNSRoleArn string
SNSTopicArn string
Options SynthesisOptions
// contains filtered or unexported fields
}
SpeechSynthesisTask represents an asynchronous synthesis task.
type SynthesisOptions ¶
type SynthesisOptions struct {
Engine string
LanguageCode string
OutputFormat string
SampleRate string
Text string
TextType string
VoiceID string
LexiconNames []string
SpeechMarkTypes []string
}
SynthesisOptions contains common synchronous and asynchronous synthesis parameters.
type SynthesizedSpeech ¶
SynthesizedSpeech is deterministic output from SynthesizeSpeech.
type Voice ¶
type Voice struct {
AdditionalLanguageCodes []string `json:"AdditionalLanguageCodes,omitempty"`
LanguageCode string `json:"LanguageCode"`
LanguageName string `json:"LanguageName"`
Gender string `json:"Gender"`
ID string `json:"Id"`
Name string `json:"Name"`
SupportedEngines []string `json:"SupportedEngines"`
}
Voice describes a voice that can be selected for synthesis.