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) 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, outputKeyPrefix, topicArn string) (*SpeechSynthesisTask, error)
- func (b *InMemoryBackend) SynthesizeSpeech(options SynthesisOptions) (*SynthesizedSpeech, error)
- type Lexicon
- type Provider
- type SpeechSynthesisTask
- type SynthesisOptions
- type SynthesizedSpeech
- 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") // 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") // ErrLexiconSizeExceeded is returned when lexicon Content exceeds the maximum lexicon size. ErrLexiconSizeExceeded = errors.New("LexiconSizeExceededException") // ErrMaxLexemeLengthExceeded is returned when a <phoneme>/<alias> replacement in // lexicon Content exceeds the maximum lexeme replacement length. ErrMaxLexemeLengthExceeded = errors.New("MaxLexemeLengthExceededException") // ErrMaxLexiconsNumberExceeded is returned when PutLexicon would create a new // lexicon beyond the per-account lexicon count quota. ErrMaxLexiconsNumberExceeded = errors.New("MaxLexiconsNumberExceededException") // ErrUnsupportedPlsAlphabet is returned when lexicon Content specifies an // alphabet other than "ipa" or "x-sampa". ErrUnsupportedPlsAlphabet = errors.New("UnsupportedPlsAlphabetException") // ErrUnsupportedPlsLanguage is returned when lexicon Content specifies an // xml:lang value outside Polly's supported LanguageCode set. ErrUnsupportedPlsLanguage = errors.New("UnsupportedPlsLanguageException") // ErrInvalidS3Bucket is returned when OutputS3BucketName is not a valid S3 bucket name. ErrInvalidS3Bucket = errors.New("InvalidS3BucketException") // ErrInvalidS3Key is returned when OutputS3KeyPrefix is not a valid S3 object key. ErrInvalidS3Key = errors.New("InvalidS3KeyException") // ErrInvalidSnsTopicArn is returned when SnsTopicArn is not a well-formed SNS topic ARN. ErrInvalidSnsTopicArn = errors.New("InvalidSnsTopicArnException") // ErrInvalidSsml is returned when TextType is "ssml" but Text is not // well-formed SSML wrapped in a <speak> root element. ErrInvalidSsml = errors.New("InvalidSsmlException") // ErrInvalidTaskID is returned when a TaskId path parameter is not a // syntactically valid task identifier (as opposed to a well-formed one that // simply does not exist, which is ErrTaskNotFound). ErrInvalidTaskID = errors.New("InvalidTaskIdException") // ErrStreamValidation is returned for StartSpeechSynthesisStream input // validation failures. AWS models this operation's client errors as the // generic smithy ValidationException, not the op-specific exceptions // (EngineNotSupportedException, InvalidSampleRateException, ...) used by // SynthesizeSpeech/StartSpeechSynthesisTask -- see // aws-sdk-go-v2/service/polly's StartSpeechSynthesisStream deserializer // error switch, which only lists ServiceFailureException, // ServiceQuotaExceededException, ThrottlingException, and ValidationException. ErrStreamValidation = errors.New("ValidationException") )
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). 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) 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, outputKeyPrefix, 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.
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
OutputS3KeyPrefix 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.