Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 45 additions & 7 deletions schemas/audioasset.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
AudioAsset:
description: >-
The AudioAsset is used to add sound effects and audio at specific intervals on
the timeline. The src must be a publicly accessible URL to an audio resource such
as an mp3 file.
description: |
The AudioAsset adds audio to a Clip. The audio can be sourced from a URL
(`src`) or generated from a text prompt (`prompt`). Exactly one of `src` or
`prompt` must be provided.

- **Source URL:** set `src` to a publicly accessible audio URL (e.g. mp3).
- **Generated speech:** set `prompt` to the spoken text and `voice` to a voice
identifier (text-to-speech). Optionally set `language`/`newscaster`.
- **Generated music or SFX:** set `prompt` describing the sound; omit `voice`.
- Use `model` to choose the generator. The generated `src` is filled in
automatically.
type: object
properties:
type:
Expand All @@ -13,11 +20,43 @@
src:
description: >-
The audio source URL. The URL must be publicly accessible or include
credentials.
credentials. Provide either `src` or `prompt`, not both.
type: string
minLength: 1
pattern: '\S'
example: https://s3-ap-northeast-1.amazonaws.com/my-bucket/sound.mp3
prompt:
description: >-
A text prompt. When `voice` is set, the prompt is the spoken text
(text-to-speech). Without `voice`, the prompt describes generated music
or sound effects. The generated `src` is filled in automatically.
type: string
maxLength: 4000
example: Welcome to today's broadcast.
voice:
description: >-
Voice identifier for text-to-speech generation (e.g. `Matthew`, `Joanna`).
Only meaningful when `prompt` is set.
type: string
example: Matthew
language:
description: >-
Optional BCP-47 language code (e.g. `en-US`) for text-to-speech.
Only meaningful when `prompt` and `voice` are set.
type: string
example: en-US
newscaster:
description: >-
Set to `true` to use the voice's newscaster mode when supported.
Only meaningful when `prompt` and `voice` are set.
type: boolean
default: false
model:
description: >-
The generation model to use when `prompt` is set (e.g. `polly-neural`).
Defaults to the platform's preferred generator if omitted.
type: string
example: polly-neural
trim:
description: >-
The start trim point of the audio clip, in seconds (defaults to 0). Audio
Expand Down Expand Up @@ -46,7 +85,7 @@
speed:
description: >-
Adjust the playback speed of the audio clip between 0 (paused) and 10 (10x normal speed), where 1 is normal
speed (defaults to 1). Adjusting the speed will also adjust the duration of the clip and may require you to
speed (defaults to 1). Adjusting the speed will also adjust the duration of the clip and may require you to
adjust the Clip length. For example, if you set speed to 0.5, the clip will need to be 2x as long to play
the entire audio (i.e. original length / 0.5). If you set speed to 2, the clip will need to be half as long
to play the entire audio (i.e. original length / 2).
Expand All @@ -72,4 +111,3 @@
additionalProperties: false
required:
- type
- src
28 changes: 23 additions & 5 deletions schemas/imageasset.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
ImageAsset:
description: >-
The ImageAsset is used to create video from images to compose an image. The src must be a
publicly accessible URL to an image resource such as a jpg or png file.
description: |
The ImageAsset adds an image to a Clip. The image can be sourced from a URL
(`src`) or generated from a text prompt (`prompt`). Exactly one of `src` or
`prompt` must be provided.

- **Source URL:** set `src` to the publicly accessible URL of a jpg or png file.
- **Generated:** set `prompt` to describe the image; the engine generates it
using the provider chosen by `model` and fills `src` in automatically.
type: object
properties:
type:
Expand All @@ -12,14 +17,27 @@
src:
description: >-
The image source URL. The URL must be publicly accessible or include
credentials.
credentials. Provide either `src` or `prompt`, not both.
type: string
minLength: 1
pattern: '\S'
example: https://s3-ap-northeast-1.amazonaws.com/my-bucket/image.jpg
prompt:
description: >-
A text prompt to generate the image from. When set without `src`, the
engine generates an image and fills `src` automatically. Use `model` to
choose the generator.
type: string
maxLength: 4000
example: A serene landscape with a crystal-clear mountain lake at sunrise.
model:
description: >-
The generation model to use when `prompt` is set (e.g. `flux-schnell`).
Defaults to the platform's preferred generator if omitted.
type: string
example: flux-schnell
crop:
$ref: "./crop.yaml#/Crop"
additionalProperties: false
required:
- type
- src
8 changes: 7 additions & 1 deletion schemas/imagetovideoasset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
ImageToVideoAsset:
description: >-
deprecated: true
description: |
**Notice: ImageToVideoAsset is deprecated. Use [VideoAsset](#tocs_videoasset)
with `prompt` and `seed` instead.** This type continues to function and is
internally rewritten to VideoAsset; no behaviour change for existing
integrations.

The ImageToVideoAsset lets you create a video from an image and a text prompt.
properties:
type:
Expand Down
7 changes: 6 additions & 1 deletion schemas/texttoimageasset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
TextToImageAsset:
description: >-
deprecated: true
description: |
**Notice: TextToImageAsset is deprecated. Use [ImageAsset](#tocs_imageasset)
with `prompt` instead.** This type continues to function and is internally
rewritten to ImageAsset; no behaviour change for existing integrations.

The TextToImageAsset lets you create a dynamic image from a text prompt.
properties:
type:
Expand Down
8 changes: 7 additions & 1 deletion schemas/texttospeechasset.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
TextToSpeechAsset:
description: >-
deprecated: true
description: |
**Notice: TextToSpeechAsset is deprecated. Use [AudioAsset](#tocs_audioasset)
with `prompt` (the spoken text) and `voice` instead.** This type continues to
function and is internally rewritten to AudioAsset; no behaviour change for
existing integrations.

The TextToSpeechAsset lets you generate a voice over from text using a text-to-speech service.
The generated audio can be trimmed, faded and have its volume and speed adjusted using the
same properties available on the AudioAsset.
Expand Down
42 changes: 35 additions & 7 deletions schemas/videoasset.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
VideoAsset:
description: >-
The VideoAsset is used to create video sequences from video files. The
src must be a publicly accessible URL to a video resource such as an mp4
file.
description: |
The VideoAsset adds a video to a Clip. The video can be sourced from a URL
(`src`) or generated from a text prompt (`prompt`), optionally seeded from a
starting image (`seed`). Exactly one of `src` or `prompt` must be provided.

- **Source URL:** set `src` to the URL of an mp4 (or compatible) video file.
- **Generated:** set `prompt` to describe the motion. Optionally set `seed` to
a starting image URL (image-to-video). Use `model` to choose the generator
(e.g. `luma-ray-3`, `runpod-itv-mini`). The generated `src` is filled in
automatically.
type: object
properties:
type:
Expand All @@ -13,11 +19,34 @@
src:
description: >-
The video source URL. The URL must be publicly accessible or include
credentials.
credentials. Provide either `src` or `prompt`, not both.
type: string
minLength: 1
pattern: '\S'
example: https://s3-ap-northeast-1.amazonaws.com/my-bucket/video.mp4
prompt:
description: >-
A text prompt to generate the video from. When set without `src`, the
engine generates a video and fills `src` automatically. Optionally pair
with `seed` for image-to-video. Use `model` to choose the generator.
type: string
maxLength: 4000
example: Slowly zoom out and orbit left around the object.
seed:
description: >-
Seed image URL for image-to-video generation. The image is used as the
starting frame; `prompt` describes the motion. Has no effect unless
`prompt` is set.
type: string
minLength: 1
example: https://s3-ap-northeast-1.amazonaws.com/my-bucket/seed-image.jpg
model:
description: >-
The generation model to use when `prompt` is set (e.g. `luma-ray-3`,
`runpod-itv-mini`). Defaults to the platform's preferred generator if
omitted.
type: string
example: luma-ray-3
transcode:
type: boolean
description: >-
Expand Down Expand Up @@ -69,7 +98,7 @@
speed:
description: >-
Adjust the playback speed of the video clip between 0 (paused) and 10 (10x normal speed) where 1 is normal
speed (defaults to 1). Adjusting the speed will also adjust the duration of the clip and may require you to
speed (defaults to 1). Adjusting the speed will also adjust the duration of the clip and may require you to
adjust the Clip length. For example, if you set speed to 0.5, the clip will need to be 2x as long to play
the entire video (i.e. original length / 0.5). If you set speed to 2, the clip will need to be half as long
to play the entire video (i.e. original length / 2).
Expand All @@ -85,4 +114,3 @@
additionalProperties: false
required:
- type
- src
39 changes: 39 additions & 0 deletions scripts/fix-discriminator.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,45 @@ function addLegacyTextWrapMigrationError(code, zPrefix) {
return code;
}

function addSrcOrPromptRefine(code, zPrefix) {
const schemaNames = [
'imageassetImageAssetSchema',
'videoassetVideoAssetSchema',
'audioassetAudioAssetSchema',
];
const strictMarker = '.strict()';
const superRefine = strictMarker + '.superRefine((data, ctx) => {\n' +
' var hasSrc = typeof data.src === "string" && data.src.trim().length > 0;\n' +
' var hasPrompt = typeof data.prompt === "string" && data.prompt.trim().length > 0;\n' +
' if (!hasSrc && !hasPrompt) {\n' +
' ctx.addIssue({\n' +
' code: ' + zPrefix + '.ZodIssueCode.custom,\n' +
' message: "A media asset requires either \\"src\\" (a source URL) or \\"prompt\\" (to generate the asset). Provide one.",\n' +
' path: ["src"],\n' +
' });\n' +
' }\n' +
'})';

for (const schemaName of schemaNames) {
const idx = code.indexOf(schemaName + ' = ');
if (idx === -1) {
console.log("⚠ src/prompt refine: could not find " + schemaName + " (" + zPrefix + ")");
continue;
}
const strictIdx = code.indexOf(strictMarker, idx);
if (strictIdx === -1 || strictIdx - idx > 6000) {
console.log("⚠ src/prompt refine: no .strict() for " + schemaName + " (" + zPrefix + ")");
continue;
}
code = code.substring(0, strictIdx) + superRefine + code.substring(strictIdx + strictMarker.length);
console.log("✓ Added src/prompt refine to " + schemaName + " (" + zPrefix + ")");
}
return code;
}

content = addStrictToObjects(content, "z");
content = addLegacyTextWrapMigrationError(content, "z");
content = addSrcOrPromptRefine(content, "z");

fs.writeFileSync(zodGenPath, content);

Expand Down Expand Up @@ -584,6 +621,7 @@ const clipClipSchemaWithFitFilter = exports.clipClipSchema.transform((clip) => {

cjsContent = addStrictToObjects(cjsContent, "zod_1.z");
cjsContent = addLegacyTextWrapMigrationError(cjsContent, "zod_1.z");
cjsContent = addSrcOrPromptRefine(cjsContent, "zod_1.z");

fs.writeFileSync(zodGenCjsPath, cjsContent);
}
Expand Down Expand Up @@ -717,6 +755,7 @@ const clipClipSchemaWithFitFilter = clipClipSchema.transform((clip) => {

jsContent = addStrictToObjects(jsContent, "z");
jsContent = addLegacyTextWrapMigrationError(jsContent, "z");
jsContent = addSrcOrPromptRefine(jsContent, "z");

fs.writeFileSync(zodGenJsPath, jsContent);
}
Expand Down
Loading
Loading