{
  "$defs": {
    "FinalCastRowV4": {
      "additionalProperties": false,
      "properties": {
        "speaker_id": {
          "pattern": "^[a-z][a-z0-9_]{0,31}$",
          "title": "Speaker Id",
          "type": "string"
        },
        "name": {
          "maxLength": 64,
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "story_function": {
          "enum": [
            "antagonist",
            "narrator",
            "other"
          ],
          "title": "Story Function",
          "type": "string"
        },
        "profile": {
          "anyOf": [
            {
              "$ref": "#/$defs/PlayCastProfile"
            },
            {
              "$ref": "#/$defs/PersonalProfile"
            }
          ],
          "title": "Profile"
        },
        "person_ref": {
          "default": null,
          "title": "Person Ref",
          "type": "null"
        },
        "voice_variation": {
          "anyOf": [
            {
              "$ref": "#/$defs/VoiceVariation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "speaker_id",
        "name",
        "story_function",
        "profile"
      ],
      "title": "FinalCastRowV4",
      "type": "object"
    },
    "PersonalProfile": {
      "additionalProperties": false,
      "properties": {
        "schema_version": {
          "const": "personal_cast_profile_1",
          "title": "Schema Version",
          "type": "string"
        },
        "name": {
          "maxLength": 64,
          "minLength": 1,
          "pattern": "\\S",
          "title": "Name",
          "type": "string"
        },
        "voice_id": {
          "format": "uuid",
          "title": "Voice Id",
          "type": "string"
        },
        "voice_revision": {
          "format": "uuid",
          "title": "Voice Revision",
          "type": "string"
        },
        "preset_id": {
          "enum": [
            "gang_natural_v1",
            "harbor_v1",
            "cedar_v1",
            "beacon_v1",
            "ember_v1",
            "spark_v1"
          ],
          "title": "Preset Id",
          "type": "string"
        },
        "language": {
          "enum": [
            "en",
            "zh",
            "de"
          ],
          "title": "Language",
          "type": "string"
        }
      },
      "required": [
        "schema_version",
        "name",
        "voice_id",
        "voice_revision",
        "preset_id",
        "language"
      ],
      "title": "PersonalProfile",
      "type": "object"
    },
    "PlayCastProfile": {
      "additionalProperties": false,
      "properties": {
        "schema_version": {
          "const": "play_cast_profile_1",
          "title": "Schema Version",
          "type": "string"
        },
        "name": {
          "maxLength": 64,
          "minLength": 1,
          "title": "Name",
          "type": "string"
        },
        "gender_presentation": {
          "enum": [
            "female",
            "male"
          ],
          "title": "Gender Presentation",
          "type": "string"
        },
        "dali_voice_id": {
          "title": "Dali Voice Id",
          "type": "string"
        },
        "age_id": {
          "enum": [
            "preschool",
            "school_age",
            "teenage",
            "twenties",
            "forties",
            "sixties",
            "over_eighty"
          ],
          "title": "Age Id",
          "type": "string"
        },
        "personality_id": {
          "enum": [
            "gentle",
            "confident",
            "curious",
            "stern",
            "playful",
            "cold_calculating",
            "menacing",
            "deceptively_charming"
          ],
          "title": "Personality Id",
          "type": "string"
        },
        "language": {
          "maxLength": 35,
          "minLength": 2,
          "pattern": "^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$",
          "title": "Language",
          "type": "string"
        }
      },
      "required": [
        "schema_version",
        "name",
        "gender_presentation",
        "dali_voice_id",
        "age_id",
        "personality_id",
        "language"
      ],
      "title": "PlayCastProfile",
      "type": "object"
    },
    "SceneUnit": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "scene",
          "title": "Kind",
          "type": "string"
        },
        "text": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "text"
      ],
      "title": "SceneUnit",
      "type": "object"
    },
    "SectionUnit": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "section",
          "title": "Kind",
          "type": "string"
        },
        "text": {
          "maxLength": 200,
          "minLength": 1,
          "title": "Text",
          "type": "string"
        }
      },
      "required": [
        "kind",
        "text"
      ],
      "title": "SectionUnit",
      "type": "object"
    },
    "SpeechUnitV4": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "speech",
          "title": "Kind",
          "type": "string"
        },
        "speaker_id": {
          "pattern": "^[a-z][a-z0-9_]{0,31}$",
          "title": "Speaker Id",
          "type": "string"
        },
        "text": {
          "maxLength": 20000,
          "minLength": 1,
          "title": "Text",
          "type": "string"
        },
        "delivery": {
          "default": "normal",
          "enum": [
            "normal",
            "question",
            "quiet",
            "energetic",
            "pause_before",
            "urgent",
            "reassuring",
            "hesitant",
            "emphatic",
            "sad",
            "angry",
            "fearful",
            "playful",
            "solemn",
            "reflective",
            "sarcastic"
          ],
          "title": "Delivery",
          "type": "string"
        },
        "personal_preset_id": {
          "anyOf": [
            {
              "enum": [
                "gang_natural_v1",
                "harbor_v1",
                "cedar_v1",
                "beacon_v1",
                "ember_v1",
                "spark_v1"
              ],
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Personal Preset Id"
        },
        "voice_variation": {
          "anyOf": [
            {
              "$ref": "#/$defs/VoiceVariation"
            },
            {
              "type": "null"
            }
          ],
          "default": null
        }
      },
      "required": [
        "kind",
        "speaker_id",
        "text"
      ],
      "title": "SpeechUnitV4",
      "type": "object"
    },
    "StanzaBreakUnit": {
      "additionalProperties": false,
      "properties": {
        "kind": {
          "const": "stanza_break",
          "title": "Kind",
          "type": "string"
        }
      },
      "required": [
        "kind"
      ],
      "title": "StanzaBreakUnit",
      "type": "object"
    },
    "VoiceVariation": {
      "additionalProperties": false,
      "properties": {
        "preset": {
          "enum": [
            "original",
            "deep",
            "cartoon",
            "custom"
          ],
          "title": "Preset",
          "type": "string"
        },
        "pitch_semitones": {
          "anyOf": [
            {
              "maximum": 7,
              "minimum": -7,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Pitch Semitones"
        },
        "resonance_ratio": {
          "anyOf": [
            {
              "maximum": 1.3,
              "minimum": 0.75,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Resonance Ratio"
        },
        "speed": {
          "anyOf": [
            {
              "maximum": 1.25,
              "minimum": 0.8,
              "type": "number"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Speed"
        }
      },
      "required": [
        "preset"
      ],
      "title": "VoiceVariation",
      "type": "object"
    }
  },
  "additionalProperties": false,
  "properties": {
    "schema_version": {
      "const": "final_audio_script_4",
      "title": "Schema Version",
      "type": "string"
    },
    "catalog_version": {
      "const": "play_cast_builder_1",
      "title": "Catalog Version",
      "type": "string"
    },
    "title": {
      "maxLength": 120,
      "minLength": 1,
      "title": "Title",
      "type": "string"
    },
    "language": {
      "maxLength": 35,
      "minLength": 2,
      "pattern": "^[a-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$",
      "title": "Language",
      "type": "string"
    },
    "content_form": {
      "anyOf": [
        {
          "enum": [
            "story",
            "fable",
            "poem",
            "speech",
            "interview",
            "play"
          ],
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Content Form"
    },
    "performance": {
      "enum": [
        "narration",
        "conversation"
      ],
      "title": "Performance",
      "type": "string"
    },
    "units": {
      "items": {
        "discriminator": {
          "mapping": {
            "scene": "#/$defs/SceneUnit",
            "section": "#/$defs/SectionUnit",
            "speech": "#/$defs/SpeechUnitV4",
            "stanza_break": "#/$defs/StanzaBreakUnit"
          },
          "propertyName": "kind"
        },
        "oneOf": [
          {
            "$ref": "#/$defs/SpeechUnitV4"
          },
          {
            "$ref": "#/$defs/SceneUnit"
          },
          {
            "$ref": "#/$defs/SectionUnit"
          },
          {
            "$ref": "#/$defs/StanzaBreakUnit"
          }
        ]
      },
      "maxItems": 2000,
      "minItems": 1,
      "title": "Units",
      "type": "array"
    },
    "cast": {
      "items": {
        "$ref": "#/$defs/FinalCastRowV4"
      },
      "maxItems": 100,
      "minItems": 1,
      "title": "Cast",
      "type": "array"
    },
    "delivery_catalog_version": {
      "const": "delivery_catalog_2",
      "title": "Delivery Catalog Version",
      "type": "string"
    },
    "voice_variation": {
      "anyOf": [
        {
          "$ref": "#/$defs/VoiceVariation"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    }
  },
  "required": [
    "schema_version",
    "catalog_version",
    "title",
    "language",
    "performance",
    "units",
    "cast",
    "delivery_catalog_version"
  ],
  "title": "FinalAudioScriptV4",
  "type": "object"
}
