File size: 1,211 Bytes
3d4392e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6215321
 
3d4392e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"use server"

import { serializeClap } from "@/lib/clap/serializeClap"
import { newClap } from "@/lib/clap/newClap"
import { getEmptyClap } from "@/lib/clap/emptyClap"

import { LatentScenes } from "./types"
import { addLatentScenesToClap } from "./addLatentScenesToClap"
import { getLatentScenes } from "./getLatentScenes"

/**
 * Generate a Clap file from scratch using a prompt
 */
export async function generateClap({
  prompt = "",
  debug = false
}: {
  prompt?: string
  debug?: boolean
} = {
  prompt: "",
  debug: false,
}): Promise<Blob> {

  const empty = await getEmptyClap()

  if (!prompt?.length) { 
    return empty
  }

  let clap = newClap({
    meta: {
      title: "Latent content", // TODO "
      description: "",
      licence: "non commercial",
      orientation: "landscape",
      width: 1024,
      height: 576,
      defaultVideoModel: "SDXL",
      extraPositivePrompt: [],
      screenplay: "",
      isLoop: true,
      isInteractive: true,
    } 
  })

  const scenes: LatentScenes = await getLatentScenes({
    prompt,
    debug,
  })


  clap = await addLatentScenesToClap({
    clap,
    scenes,
    debug,
  })

  const archive = await serializeClap(clap)

  return archive
}