{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.bayanatlabs.com/research/arabic-tts-inspection-kit/v0.1/schema.json",
  "title": "Arabic studio utterance record (Bayanat Labs TTS inspection kit v0.1)",
  "description": "One recorded studio utterance with its script, reading, style, audio, inspection result and rights. Each right is recorded separately; a missing right is 'not_stated', never assumed.",
  "type": "object",
  "required": ["utterance_id", "speaker_id", "script_id", "text", "variety", "style_label", "audio", "inspection", "rights"],
  "properties": {
    "utterance_id": { "type": "string" },
    "speaker_id": { "type": "string", "description": "Pseudonymous speaker ID. Never a name." },
    "script_id": { "type": "string", "description": "ID of the script line, e.g. TK07." },
    "text": { "type": "string", "description": "The plain text as given to the speaker or the TTS system." },
    "reference_reading": { "type": "string", "description": "The intended reading with diacritics on the tested words, for the listener. Not a training transcript." },
    "transcript_as_spoken": { "type": "string", "description": "What was actually said, fully vowelled, written after listening." },
    "variety": { "type": "string", "enum": ["msa", "saudi", "saudi_najdi", "saudi_hijazi", "gulf", "egyptian", "levantine", "maghrebi", "other"] },
    "style_label": { "type": "string", "description": "From the project's style list, e.g. neutral, empathetic, cheerful, urgent." },
    "audio": {
      "type": "object",
      "required": ["path", "sample_rate_hz", "channels", "duration_s"],
      "properties": {
        "path": { "type": "string" },
        "format": { "type": "string", "examples": ["wav"] },
        "sample_rate_hz": { "type": "integer" },
        "bit_depth": { "type": "integer" },
        "channels": { "type": "integer" },
        "duration_s": { "type": "number" }
      }
    },
    "recording": {
      "type": "object",
      "properties": {
        "session_id": { "type": "string" },
        "session_date": { "type": "string", "format": "date" },
        "room": { "type": "string" },
        "microphone": { "type": "string" },
        "director_notes": { "type": "string" }
      }
    },
    "inspection": {
      "type": "object",
      "required": ["result", "errors"],
      "properties": {
        "result": { "type": "string", "enum": ["pass", "fail", "rerecord"] },
        "errors": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["code", "word"],
            "properties": {
              "code": { "type": "string", "enum": ["SUN_ASSIM", "MOON_LAM", "WASL", "PAUSAL", "TA_MARBUTA", "GEMINATION", "HOMOGRAPH", "NUM_GENDER", "NUM_VERBALIZE", "ABBREV", "DATE_POLICY", "PROSODY_QUESTION", "DIALECT_LEXICON", "QAF_REALIZATION", "CODESWITCH", "STYLE_MISMATCH", "AUDIO_DEFECT"] },
              "word": { "type": "string" },
              "heard": { "type": "string" },
              "note": { "type": "string" }
            }
          }
        },
        "style_match": { "type": "integer", "minimum": 0, "maximum": 2, "description": "0 = wrong style, 1 = recognizable but flat or overdone, 2 = matches the label." },
        "inspector_id": { "type": "string" }
      }
    },
    "rights": {
      "type": "object",
      "description": "Each use is a separate permission. Values: granted, not_granted, not_stated.",
      "required": ["asr_training", "tts_training", "synthetic_voice_of_speaker", "redistribution", "commercial_use", "consent_record_id"],
      "properties": {
        "asr_training": { "$ref": "#/$defs/permission" },
        "tts_training": { "$ref": "#/$defs/permission" },
        "synthetic_voice_of_speaker": { "$ref": "#/$defs/permission", "description": "May a reusable synthetic voice that sounds like this speaker be created?" },
        "redistribution": { "$ref": "#/$defs/permission" },
        "commercial_use": { "$ref": "#/$defs/permission" },
        "permitted_users": { "type": "string", "description": "Who may use a resulting voice, if one is permitted." },
        "exclusivity": { "type": "string", "enum": ["exclusive", "non_exclusive", "not_stated"] },
        "expires": { "type": ["string", "null"], "format": "date" },
        "consent_record_id": { "type": "string", "description": "Pointer to the signed consent or contract. Never the document itself." }
      }
    },
    "illustrative": { "type": "boolean", "description": "true on the example records in this kit." }
  },
  "$defs": {
    "permission": { "type": "string", "enum": ["granted", "not_granted", "not_stated"] }
  }
}
