polly

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 27 Imported by: 0

README

Polly

Parity grade: A · SDK aws-sdk-go-v2/service/polly@v1.57.5 · last audited 2026-07-13 (b0d0cfe0)

Coverage

Metric Value
Operations audited 13 (12 ok, 1 partial)
Feature families 4 (4 ok)
Known gaps 8
Deferred items 5
Resource leaks clean
Known gaps
  • TagResource/UntagResource/ListTagsForResource + the /v1/tags/{arn} routes are NOT part of the real Amazon Polly API (confirmed: aws-sdk-go-v2/service/polly has no such api_op_*.go files, and service-2.json's operation list omits them entirely). This is gopherstack-invented functionality, not a wire-shape bug -- no genuine SDK client can reach these routes, so it's harmless, but it is not real AWS surface. Left in place (fully functional, not a stub) rather than removed, since removal is a larger behavioral change outside a parity-bugfix pass. (bd: file follow-up to confirm intentional and document, or remove)
  • Built-in voice catalogue (backend.go builtInVoices) covers ~90 of the real ~112 VoiceId enum values from aws-sdk-go-v2/service/polly/types. Missing IDs include Geraint, Zeina, Hiujin, Tomoko, Zayd, Danielle, Gregory, Jitka, Sabrina, Jasmine, Jihye, Ambre, Beatrice, Florian, Lennart, Lorenzo, Tiffany, Andres, and Arabic (arb) support. Not fabricated data -- a real but incomplete subset. Completing the catalogue is a larger, lower-risk-tolerance change deferred from this pass.
  • PutLexicon does not implement LexiconSizeExceededException, MaxLexemeLengthExceededException, MaxLexiconsNumberExceededException, UnsupportedPlsAlphabetException, or UnsupportedPlsLanguageException -- these require new quota/PLS-schema validation logic (not just error-type remapping of existing checks) and exact AWS quota numbers that were not available to verify confidently in this pass.
  • StartSpeechSynthesisTask does not validate OutputS3BucketName/OutputS3KeyPrefix format (InvalidS3BucketException/InvalidS3KeyException) or SnsTopicArn format (InvalidSnsTopicArnException); any string is accepted. New validation, deferred.
  • SynthesizeSpeech/StartSpeechSynthesisTask do not validate SSML well-formedness (InvalidSsmlException) when TextType=ssml; any string is accepted as SSML. New validation, deferred.
  • ListSpeechSynthesisTasks MaxResults out-of-range still returns generic InvalidParameterValueException; the real service-2.json model lists no MaxResults-specific exception for this op at all, so correct AWS behavior here (clamp vs error) is unconfirmed -- left as-is rather than guessed.
  • DescribeVoices ignores any NextToken query parameter (always returns the full catalogue in one page, never emits NextToken). The real API does support NextToken/pagination per paginators-1.json, but returning everything in a single page is valid AWS behavior (paginated APIs may return all results in the first page) -- not changed.
  • StartSpeechSynthesisStream's error taxonomy stays generic InvalidParameterValueException; the real op's documented errors are ValidationException/ServiceQuotaExceededException/ThrottlingException, none of which map cleanly onto today's validation without additional behavioral changes (e.g., real throttling simulation). Deferred.
Deferred
  • StartSpeechSynthesisStream error taxonomy
  • Lexicon quota/PLS-schema validation (LexiconSizeExceeded, MaxLexemeLength, MaxLexiconsNumber, UnsupportedPlsAlphabet/Language)
  • S3 bucket/key and SNS topic ARN format validation on StartSpeechSynthesisTask
  • SSML well-formedness validation
  • Full VoiceId catalogue completion

More

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func (h *Handler) ChaosOperations() []string

ChaosOperations returns injectable operation list.

func (*Handler) ChaosRegions

func (h *Handler) ChaosRegions() []string

ChaosRegions returns backend region.

func (*Handler) ChaosServiceName

func (h *Handler) ChaosServiceName() string

ChaosServiceName returns service key.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(c *echo.Context) string

ExtractOperation derives operation from request method and path.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(c *echo.Context) string

ExtractResource derives task ID, lexicon name, or ARN from request path.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations returns implemented SDK operations.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns request dispatcher.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority returns REST service routing priority.

func (*Handler) Name

func (h *Handler) Name() string

Name returns service name.

func (*Handler) Reset

func (h *Handler) Reset()

Reset clears backend state.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher matches versioned Polly routes.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

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) Reset

func (b *InMemoryBackend) Reset()

Reset clears stored resources.

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

Init initializes Polly backend and REST handler.

func (*Provider) Name

func (p *Provider) Name() string

Name returns provider name.

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

type SynthesizedSpeech struct {
	ContentType       string
	Data              []byte
	RequestCharacters int
}

SynthesizedSpeech is deterministic output from SynthesizeSpeech.

type Tag

type Tag struct {
	Key   string `json:"Key"`
	Value string `json:"Value"`
}

Tag is a Polly resource tag.

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.

Jump to

Keyboard shortcuts

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