an.audio.tts#
TTS provider protocol + supporting dataclasses.
Classes
|
A rendered audio clip, on disk or in memory. |
|
Text-to-speech provider. |
|
Metadata for a TTS voice as exposed by a provider. |
- class an.audio.tts.AudioClip(path=None, bytes_=None, duration=0.0, sample_rate=44100, channels=1, voice_id=None, transcript=None, words=None, phones=None, phone_alphabet=None)[source]#
Bases:
objectA rendered audio clip, on disk or in memory.
- phone_alphabet: str | None#
The alphabet
phonesare in ("arpabet","ipa"), as the take’s record states it (an#637, an#721);Nonewhen unknown, and a lip-sync provider then guesses from the labels (an#726).
- phones: list[tuple[str, float, float]] | None#
The clip’s phone timings,
(phone, start_s, end_s)from the clip’s start, when an aligner gave them (a TextGrid’sphonestier on a recorded take, an#491);Noneotherwise. A lip-sync provider that maps phones to mouth shapes can use them instead of spreading letters.
- words: list[tuple[str, float, float]] | None#
The clip’s word timings —
(word, start_s, end_s)from the clip’s start — when the provider knows them (a recorded take imported with a timed transcript:an.audio.recorded);Noneotherwise. A lip-sync provider that aligns from words prefers these to its own transcription, and the audio pipeline stamps them on the line.
- class an.audio.tts.VoiceMeta(voice_id, name, provider, language='en', gender=None, extra=dict(), is_stock=None, accent=None, description=None, preview_url=None)[source]#
Bases:
objectMetadata for a TTS voice as exposed by a provider.
The fields are the provider-neutral facts a host shows and filters on (an#712):
is_stockis the provider’s own answer to “nobody designed this” — one of its stock voices (ElevenLabs’ premade voices, a system voice) rather than one an account designed, cloned, recorded or added from a shared voice library;accent,descriptionandpreview_url(a sample to hear before casting, an#666) areNonewhere the provider has none, andis_stockisNonewhere it does not say.extrais the provider’s own detail, in its own words. Keys hosts read (a contract): ElevenLabs’scategoryandlabels. Itsdescriptionandpreview_urlkeys repeat the fields for one more cycle (hosts readextra["preview_url"]since an#666): read the fields.as_row()is the flat, JSON-ready view a host lists (an.audio.list_voices()).>>> VoiceMeta("v1", "Rachel", "elevenlabs", is_stock=True, accent="american", ... extra={"category": "premade", "labels": {"age": "young"}}).as_row() ... {'voice_id': 'v1', 'name': 'Rachel', 'provider': 'elevenlabs', 'language': 'en', 'gender': None, 'is_stock': True, 'accent': 'american', 'description': None, 'preview_url': None, 'category': 'premade'}