Module adcp.types.domains.formats.canonical.audio_hosted

Classes

class AssetSource (*args, **kwds)
Expand source code
class AssetSource(StrEnum):
    buyer_uploaded = 'buyer_uploaded'
    publisher_host_recorded = 'publisher_host_recorded'
    seller_pre_rendered_from_brief = 'seller_pre_rendered_from_brief'
    seller_human_designed = 'seller_human_designed'
    agent_synthesized = 'agent_synthesized'
    publisher_owned_reference = 'publisher_owned_reference'

Enum where members are also (and must be) strings

Ancestors

  • enum.StrEnum
  • builtins.str
  • enum.ReprEnum
  • enum.Enum

Class variables

var agent_synthesized
var buyer_uploaded
var publisher_host_recorded
var publisher_owned_reference
var seller_human_designed
var seller_pre_rendered_from_brief
class AudioChannel (*args, **kwds)
Expand source code
class AudioChannel(StrEnum):
    mono = 'mono'
    stereo = 'stereo'

Enum where members are also (and must be) strings

Ancestors

  • enum.StrEnum
  • builtins.str
  • enum.ReprEnum
  • enum.Enum

Class variables

var mono
var stereo
class AudioCodec (*args, **kwds)
Expand source code
class AudioCodec(StrEnum):
    mp3 = 'mp3'
    aac = 'aac'
    wav = 'wav'
    opus = 'opus'
    flac = 'flac'

Enum where members are also (and must be) strings

Ancestors

  • enum.StrEnum
  • builtins.str
  • enum.ReprEnum
  • enum.Enum

Class variables

var aac
var flac
var mp3
var opus
var wav
class AudioSampleRate (value: Any = <object object>, *, root: Any = <object object>)
Expand source code
class AudioSampleRate(ScalarInt):
    __slots__ = ()
    _constraints = {'ge': 1}

An int generated from a JSON Schema integer root.

Validates the way SchemaInt validates an integer field: strict, so "1" and True are refused, with a float carrying no fractional part narrowed to int because JSON Schema counts it as one.

Ancestors

  • adcp.types._scalar.ScalarInt
  • adcp.types._scalar._ScalarRoot
  • builtins.int
class BuyerAssetAcceptance (*args, **kwds)
Expand source code
class BuyerAssetAcceptance(StrEnum):
    accepted = 'accepted'
    rejected = 'rejected'

Enum where members are also (and must be) strings

Ancestors

  • enum.StrEnum
  • builtins.str
  • enum.ReprEnum
  • enum.Enum

Class variables

var accepted
var rejected
class CanonicalFormatHostedAudio (**data: Any)
Expand source code
class CanonicalFormatHostedAudio(CanonicalFormatBase):
    model_config = ConfigDict(
        extra='allow',
    )
    slots: Annotated[
        Any | None,
        Field(
            description="Default slots for buyer-uploaded audio. Host-read products override with a `script` (asset_type: text) or `creative_brief` (asset_type: brief) slot in place of `audio_main`, plus `asset_source: 'publisher_host_recorded'` and `buyer_asset_acceptance: 'rejected'`. TTS-from-script products override similarly with `asset_source: 'seller_pre_rendered_from_brief'`."
        ),
    ] = [
        {'asset_group_id': 'audio_main', 'asset_type': 'audio', 'required': True},
        {'asset_group_id': 'companion_image', 'asset_type': 'image', 'required': False},
        {'asset_group_id': 'brand_name', 'asset_type': 'text', 'required': False},
        {'asset_group_id': 'landing_page_url', 'asset_type': 'url', 'required': False},
    ]
    duration_ms_range: Annotated[
        list[DurationMsRange | None] | None,
        Field(
            description='[min, max] duration in milliseconds. Either endpoint MAY be null to express an unbounded side: [null, 60000] means up to 60s; [15000, null] means at least 15s. [null, null] is invalid because at least one endpoint must be bounded. **Precedence**: when both `duration_ms_exact` and `duration_ms_range` ship on the same product, `duration_ms_exact` takes precedence — buyers MUST validate against the exact value and ignore the range. SDKs SHOULD lint a warning when both fields ship; producers SHOULD pick one.',
            max_length=2,
            min_length=2,
        ),
    ] = None
    duration_ms_exact: Annotated[
        SchemaInt | None,
        Field(
            description='When set, duration must equal exactly this value. Takes precedence over `duration_ms_range` when both ship.',
            ge=1,
        ),
    ] = None
    audio_codecs: list[AudioCodec] | None = None
    audio_sample_rates: list[AudioSampleRate] | None = None
    audio_channels: list[AudioChannel] | None = None
    min_bitrate_kbps: Annotated[SchemaInt | None, Field(ge=1)] = None
    max_bitrate_kbps: Annotated[SchemaInt | None, Field(ge=1)] = None
    max_file_size_mb: Annotated[
        StrictFloat | None,
        Field(
            description='Maximum hosted audio file size in decimal megabytes. Agents that proxy or cache media SHOULD advertise their effective transport ceiling here.',
            gt=0.0,
        ),
    ] = None
    loudness_lufs: Annotated[
        StrictFloat | None,
        Field(
            description='Required integrated loudness in LUFS (typical: -16 for streaming/podcast, -23 for broadcast). Negative values.'
        ),
    ] = None
    loudness_tolerance_db: Annotated[
        StrictFloat | None,
        Field(description='Permitted deviation from loudness_lufs in dB.', ge=0.0),
    ] = None
    true_peak_dbfs: Annotated[
        StrictFloat | None, Field(description='Maximum true-peak level in dBFS (typical: -2).')
    ] = None
    asset_source: Annotated[
        AssetSource | None,
        Field(
            description="Where the rendered audio bytes come from. Single shared enum across canonicals (see `image.json#asset_source` for the full semantics). `publisher_host_recorded`: the publisher's host records the audio (podcast host-read pattern); buyer must use the publisher's build_creative capability. `publisher_owned_reference` is valid only when the product accepts a reference asset whose publisher-owned source resolves to playable audio. `publisher_host_recorded` remains the normal audio-specific host-read value."
        ),
    ] = AssetSource.buyer_uploaded
    buyer_asset_acceptance: Annotated[
        BuyerAssetAcceptance | None,
        Field(
            description="Whether the product accepts buyer-uploaded audio. When `rejected`, the buyer cannot ship an audio asset directly — they must use build_creative (or sync_creatives with brief inputs) so the seller produces the audio. Combined with `asset_source`, lets a product declare 'I produce audio from briefs and refuse buyer uploads' (asset_source=`seller_pre_rendered_from_brief`, buyer_asset_acceptance=`rejected`)."
        ),
    ] = BuyerAssetAcceptance.accepted
    companion_image_required: StrictBool | None = None
    companion_image_aspect_ratio: str | None = None
    companion_image_max_file_size_kb: Annotated[SchemaInt | None, Field(ge=1)] = None
    brand_name_max_chars: Annotated[SchemaInt | None, Field(ge=1)] = None

Base model for AdCP types with spec-compliant serialization.

Defaults to extra='ignore' so unknown fields from newer spec versions are silently dropped rather than causing validation errors. Generated types whose schemas set additionalProperties: true override this with extra='allow' in their own model_config.

Set ADCP_STRICT_VALIDATION=1 in the environment ("1", "true", "yes", "on" are accepted) to flip the default to extra='forbid'. Use this during spec upgrades to catch silently-dropped renamed fields in tests. See :func:_resolve_extra_policy.

Important

The env var is resolved once at module import time. Set it in your shell or CI environment before import adcp runs — mutating os.environ["ADCP_STRICT_VALIDATION"] after the first adcp import has no effect on already-imported model classes (they captured the policy at class-body evaluation).

Consumers who want per-model strict validation can override model_config on their subclass.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Ancestors

  • adcp.types.domains.formats.canonical._base.CanonicalFormatBase
  • AdCPBaseModel
  • pydantic.main.BaseModel

Class variables

var asset_source : AssetSource | None
var audio_channels : list[AudioChannel] | None
var audio_codecs : list[AudioCodec] | None
var audio_sample_rates : list[AudioSampleRate] | None
var brand_name_max_chars : int | None
var buyer_asset_acceptance : BuyerAssetAcceptance | None
var companion_image_aspect_ratio : str | None
var companion_image_max_file_size_kb : int | None
var companion_image_required : bool | None
var duration_ms_exact : int | None
var duration_ms_range : list[DurationMsRange | None] | None
var loudness_lufs : float | None
var loudness_tolerance_db : float | None
var max_bitrate_kbps : int | None
var max_file_size_mb : float | None
var min_bitrate_kbps : int | None
var model_config
var slots : typing.Any | None
var true_peak_dbfs : float | None

Inherited members

class DurationMsRange (value: Any = <object object>, *, root: Any = <object object>)
Expand source code
class DurationMsRange(ScalarInt):
    __slots__ = ()
    _constraints = {'ge': 0}

An int generated from a JSON Schema integer root.

Validates the way SchemaInt validates an integer field: strict, so "1" and True are refused, with a float carrying no fractional part narrowed to int because JSON Schema counts it as one.

Ancestors

  • adcp.types._scalar.ScalarInt
  • adcp.types._scalar._ScalarRoot
  • builtins.int