{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/google/json-schema/google-speech-generation-request-schema.json",
  "title": "SpeechGenerationRequest",
  "x-generated": "2026-11-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/google-speech-generation-api-openapi.yml#/components/schemas/SpeechGenerationRequest",
  "type": "object",
  "required": [
    "contents",
    "generationConfig"
  ],
  "properties": {
    "contents": {
      "type": "array",
      "description": "Text content to convert to speech",
      "items": {
        "$ref": "#/$defs/Content"
      }
    },
    "generationConfig": {
      "$ref": "#/$defs/SpeechGenerationConfig",
      "description": "Configuration for speech generation"
    }
  },
  "$defs": {
    "Content": {
      "type": "object",
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "user",
            "model"
          ],
          "description": "The role of the content producer (optional for single-turn, required for multi-turn)"
        },
        "parts": {
          "type": "array",
          "description": "Ordered parts that constitute a single message",
          "items": {
            "$ref": "#/$defs/Part"
          }
        }
      },
      "required": [
        "parts"
      ]
    },
    "FileData": {
      "type": "object",
      "description": "Reference to a file uploaded via the File API or a YouTube URL",
      "properties": {
        "mime_type": {
          "type": "string",
          "description": "MIME type of the file (optional for YouTube URLs)"
        },
        "file_uri": {
          "type": "string",
          "description": "URI of the file from File API or YouTube URL"
        }
      },
      "required": [
        "file_uri"
      ]
    },
    "InlineData": {
      "type": "object",
      "required": [
        "mime_type",
        "data"
      ],
      "properties": {
        "mime_type": {
          "type": "string",
          "description": "MIME type of the data",
          "enum": [
            "image/jpeg",
            "image/png",
            "image/webp",
            "video/mp4",
            "video/mpeg",
            "video/mov",
            "video/avi",
            "video/x-flv",
            "video/mpg",
            "video/webm",
            "video/wmv",
            "video/3gpp",
            "audio/wav",
            "audio/mp3",
            "audio/aiff",
            "audio/aac",
            "audio/ogg",
            "audio/flac",
            "application/pdf"
          ]
        },
        "data": {
          "type": "string",
          "format": "byte",
          "description": "Base64 encoded data"
        }
      }
    },
    "MultiSpeakerVoiceConfig": {
      "type": "object",
      "required": [
        "speakerVoiceConfigs"
      ],
      "properties": {
        "speakerVoiceConfigs": {
          "type": "array",
          "description": "Voice configurations for each speaker (maximum 2)",
          "minItems": 2,
          "maxItems": 2,
          "items": {
            "$ref": "#/$defs/SpeakerVoiceConfig"
          }
        }
      }
    },
    "Part": {
      "type": "object",
      "description": "A part of the content, can be text, inline data, or file data",
      "oneOf": [
        {
          "type": "object",
          "required": [
            "text"
          ],
          "properties": {
            "text": {
              "type": "string",
              "description": "Text content"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "inline_data"
          ],
          "properties": {
            "inline_data": {
              "$ref": "#/$defs/InlineData"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "file_data"
          ],
          "properties": {
            "file_data": {
              "$ref": "#/$defs/FileData"
            },
            "video_metadata": {
              "$ref": "#/$defs/VideoMetadata",
              "description": "Optional metadata for video processing (clipping, FPS)"
            }
          }
        }
      ]
    },
    "PrebuiltVoiceConfig": {
      "type": "object",
      "required": [
        "voiceName"
      ],
      "properties": {
        "voiceName": {
          "type": "string",
          "description": "Name of the prebuilt voice with characteristic (Bright, Upbeat, Informative, etc.)",
          "enum": [
            "Zephyr",
            "Puck",
            "Charon",
            "Kore",
            "Fenrir",
            "Leda",
            "Orus",
            "Aoede",
            "Callirrhoe",
            "Autonoe",
            "Enceladus",
            "Iapetus",
            "Umbriel",
            "Algieba",
            "Despina",
            "Erinome",
            "Algenib",
            "Rasalgethi",
            "Laomedeia",
            "Achernar",
            "Alnilam",
            "Schedar",
            "Gacrux",
            "Pulcherrima",
            "Achird",
            "Zubenelgenubi",
            "Vindemiatrix",
            "Sadachbia",
            "Sadaltager",
            "Sulafat"
          ]
        }
      }
    },
    "SpeakerVoiceConfig": {
      "type": "object",
      "required": [
        "speaker",
        "voiceConfig"
      ],
      "properties": {
        "speaker": {
          "type": "string",
          "description": "Name of the speaker (must match names used in prompt)"
        },
        "voiceConfig": {
          "$ref": "#/$defs/VoiceConfig",
          "description": "Voice configuration for this speaker"
        }
      }
    },
    "SpeechConfig": {
      "type": "object",
      "description": "Configuration for single or multi-speaker speech",
      "oneOf": [
        {
          "type": "object",
          "required": [
            "voiceConfig"
          ],
          "properties": {
            "voiceConfig": {
              "$ref": "#/$defs/VoiceConfig",
              "description": "Single-speaker voice configuration"
            }
          }
        },
        {
          "type": "object",
          "required": [
            "multiSpeakerVoiceConfig"
          ],
          "properties": {
            "multiSpeakerVoiceConfig": {
              "$ref": "#/$defs/MultiSpeakerVoiceConfig",
              "description": "Multi-speaker voice configuration (up to 2 speakers)"
            }
          }
        }
      ]
    },
    "SpeechGenerationConfig": {
      "type": "object",
      "required": [
        "responseModalities",
        "speechConfig"
      ],
      "properties": {
        "responseModalities": {
          "type": "array",
          "description": "Must include \"AUDIO\" for TTS",
          "items": {
            "type": "string",
            "enum": [
              "AUDIO"
            ]
          }
        },
        "speechConfig": {
          "$ref": "#/$defs/SpeechConfig",
          "description": "Configuration for speech output"
        }
      }
    },
    "VideoMetadata": {
      "type": "object",
      "description": "Metadata for customizing video processing",
      "properties": {
        "start_offset": {
          "type": "string",
          "description": "Start time offset for video clipping (format like \"1250s\")",
          "pattern": "^\\d+s$"
        },
        "end_offset": {
          "type": "string",
          "description": "End time offset for video clipping (format like \"1570s\")",
          "pattern": "^\\d+s$"
        },
        "fps": {
          "type": "number",
          "format": "float",
          "description": "Custom frame rate sampling (frames per second). Default is 1 FPS. Use <1 for long videos, >1 for rapidly changing visuals",
          "minimum": 0.1
        }
      }
    },
    "VoiceConfig": {
      "type": "object",
      "required": [
        "prebuiltVoiceConfig"
      ],
      "properties": {
        "prebuiltVoiceConfig": {
          "$ref": "#/$defs/PrebuiltVoiceConfig"
        }
      }
    }
  }
}