ttscontract

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package ttscontract provides a reusable conformance suite that every tts.Provider implementation is expected to satisfy.

Like its STT sibling, it centralises the cross-provider invariants — stable identity, a valid deployment Kind, provider-stamped non-empty audio results, HTTP-error propagation, and context cancellation — so a provider test only supplies a constructor and a success-response handler, then calls RunContract.

The harness lives in a non-test package so it can be shared across provider packages. Conformance tests must live in an external test package (e.g. `package tts_test`) to avoid the import cycle that would form (ttscontract imports tts).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunContract

func RunContract(t *testing.T, c Case)

RunContract executes the full TTS conformance suite for c.

Types

type Case

type Case struct {
	// Name is a short label used to namespace the subtests (e.g. "openai").
	Name string

	// ExpectedName is the stable identifier the provider must return from
	// Name() and stamp onto Result.Provider for a successful synthesis.
	ExpectedName string

	// NewProvider builds the provider bound to baseURL, an httptest server URL.
	// The provider must be configured to accept that loopback URL (relaxed
	// netsec validation).
	NewProvider func(baseURL string) tts.Provider

	// Success serves exactly one successful synthesis response in the
	// provider's wire format (raw audio bytes or a JSON envelope).
	Success http.HandlerFunc
}

Case describes a single TTS provider under conformance test.

Jump to

Keyboard shortcuts

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