an.audio.shared_mixing#

The fleet’s shared audio component, mixing, as an imports it.

mixing is a core dependency (an#611), so the way a part of it goes missing is a mixing older than that part. mixing_too_old() is the one wording of that failure, used around the lazy imports in an.audio.loudness (mixing.loudness) and an.audio.effects (mixing.filtergraph). The imports themselves stay written out where they are, so the licence firewall (tests/test_captions.py::test_an_never_imports_mixing) still reads them.

A keyword an passes cannot be found by importing a name: an older function takes the call and fails on it. lacks_keywords() asks the function’s signature instead (level_group(subject=), mixing#171, an#765), and mixing_problem() and an.audio.loudness word a missing one as a mixing too old, like a missing part.

>>> with mixing_too_old(needed_for="testing", error=RuntimeError):
...     from mixing import no_such_part
Traceback (most recent call last):
  ...
RuntimeError: testing needs mixing.no_such_part, which the installed mixing is too old to have: `pip install -U mixing`

A name missing from a module that exists is named in full:

>>> with mixing_too_old(needed_for="testing", error=RuntimeError):
...     from mixing.loudness import no_such_name
Traceback (most recent call last):
  ...
RuntimeError: testing needs mixing.loudness.no_such_name, which the installed mixing is too old to have: `pip install -U mixing`

Module Attributes

MIXING

The package, and what the user runs when theirs predates a part an needs.

INSTALL_HINT

LEVEL_GROUP_KEYWORDS

subject names the voice in its GainCappedWarning (mixing#171, an#765).

Functions

keywords_too_old(func, keywords, *, needed_for)

Why func (a function of mixing) cannot serve needed_for: the keywords of keywords it does not take, worded as a mixing too old; None when it takes them all.

lacks_keywords(func, keywords)

The keywords func does not take (none when it takes **kwargs, or when its signature cannot be read: the call then says for itself).

mixing_problem()

Why the installed mixing cannot serve an: a part it uses is missing (mixing.loudness with group_lufs and GainCappedWarning, an#699; mixing.filtergraph), a keyword an passes is not taken (level_group(subject=), an#765), or it is absent; None when it can.

mixing_too_old(*, needed_for, error)

Run an import of a part of mixing; an ImportError becomes error, saying the installed mixing is too old when it lacks the part, else what failed.

warn_if_mixing_too_old()

Say once per process, before anything is billed, that the installed mixing cannot serve an (mixing_problem()): the entry points that may bill (a render, an voices design, audition and reroll) call it, so an old mixing is not found after synthesis (an#644).

Exceptions

MixingTooOldWarning

The installed mixing lacks a part an uses (or is absent).

an.audio.shared_mixing.INSTALL_HINT: str = 'pip install mixing'#

… and when it is not installed at all (an install with --no-deps).

an.audio.shared_mixing.LEVEL_GROUP_KEYWORDS: tuple[str, ...] = ('subject',)#

subject names the voice in its GainCappedWarning (mixing#171, an#765).

Type:

The keywords an passes to mixing.loudness.level_group()

an.audio.shared_mixing.MIXING: str = 'mixing'#

The package, and what the user runs when theirs predates a part an needs.

exception an.audio.shared_mixing.MixingTooOldWarning[source]#

Bases: UserWarning

The installed mixing lacks a part an uses (or is absent).

an.audio.shared_mixing.keywords_too_old(func, keywords, *, needed_for)[source]#

Why func (a function of mixing) cannot serve needed_for: the keywords of keywords it does not take, worded as a mixing too old; None when it takes them all.

>>> def level_group(segments, rate): ...
>>> level_group.__module__ = "mixing.loudness"
>>> keywords_too_old(level_group, ["subject"], needed_for="testing")
'testing needs mixing.loudness.level_group(subject=), which the installed mixing is too old to have: `pip install -U mixing`'
Return type:

str | None

an.audio.shared_mixing.lacks_keywords(func, keywords)[source]#

The keywords func does not take (none when it takes **kwargs, or when its signature cannot be read: the call then says for itself).

>>> def old(segments, rate, *, target_lufs): ...
>>> lacks_keywords(old, ["target_lufs", "subject"])
['subject']
>>> lacks_keywords(lambda *a, **kw: None, ["subject"])
[]
Return type:

list[str]

an.audio.shared_mixing.mixing_problem()[source]#

Why the installed mixing cannot serve an: a part it uses is missing (mixing.loudness with group_lufs and GainCappedWarning, an#699; mixing.filtergraph), a keyword an passes is not taken (level_group(subject=), an#765), or it is absent; None when it can. Asked of the code, not of a version number: an editable install’s metadata keeps the version it was installed at (an#644).

Return type:

str | None

an.audio.shared_mixing.mixing_too_old(*, needed_for, error)[source]#

Run an import of a part of mixing; an ImportError becomes error, saying the installed mixing is too old when it lacks the part, else what failed.

Return type:

Iterator[None]

an.audio.shared_mixing.warn_if_mixing_too_old()[source]#

Say once per process, before anything is billed, that the installed mixing cannot serve an (mixing_problem()): the entry points that may bill (a render, an voices design, audition and reroll) call it, so an old mixing is not found after synthesis (an#644). mixing_too_old() stays the backstop at each import.

Return type:

None