espnet3.contract.field.Field
About 1 min
espnet3.contract.field.Field
class espnet3.contract.field.Field(name: str, kind: str, label: str = '', optional: bool = False, channels: int | None = None, options: ~collections.abc.Mapping[str, ~typing.Any] = <factory>)
Bases: object
One input or output of a system.
A system lists these in its inputs and outputs; the base class binds arguments to them, converts and checks values by kind, and a front end builds its widgets or command-line arguments from them.
- Parameters:
- name – The keyword the value is passed or returned as, such as
speechortext. Must be a Python identifier. - kind – A name in
KINDS. Decides how a value is converted and checked (audiobecomes anAudioat the model’s rate,textmust be astr) and, for a front end, which widget or argument type shows it. - label – What a page calls the field. Defaults to the name with underscores spaced and the first letter capitalised.
- optional – An input the caller may leave out; the hook then does not receive it. Outputs are never optional.
- channels – Required audio channel count, or
None(default) to preserve every channel. Channel selection and averaging are explicit audio normalizers. - options – Kind-specific settings, such as
sample_rateornormalize. The registered Kind validates these options.
- name – The keyword the value is passed or returned as, such as
- Raises:ValueError – If
kindis not registered inKINDS,nameis not an identifier, orchannelsis below 1.
Examples
>>> Field("speech", "audio").kind
'audio'
>>> Field("reference_speech", "audio", optional=True).label
'Reference speech'
>>> Field("text", "text", "Transcription").label
'Transcription'
>>> Field("mixture", "audio", channels=None).channels # a multichannel model
>>> Field("speech", "audio").channels is None
Truechannels : int | None = None
kind : str
label : str = ''
name : str
optional : bool = False
options : Mapping[str, Any]
