File size: 3,434 Bytes
03644bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52d39bb
 
 
 
 
 
03644bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5cc7f12
03644bc
 
 
 
 
 
 
 
5cc7f12
 
 
 
 
 
52d39bb
5cc7f12
 
 
03644bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { ClapOutputType, ClapProject, ClapSegmentCategory, newClap, newSegment } from "@aitube/clap"

import { defaultSegmentDurationInMs, demoStory } from "./samples"

export function generateClapFromPrompt({
  story = demoStory,
  showIntroPoweredByEngine = false,
  showIntroDisclaimerAboutAI = false,
}: {
  story?: string[]
  showIntroPoweredByEngine?: boolean
  showIntroDisclaimerAboutAI?: boolean
} = {
  story: demoStory,
  showIntroPoweredByEngine: false,
  showIntroDisclaimerAboutAI: false,
}): ClapProject {

  const clap = newClap({
    meta: {
      title: "Interactive Demo",
      isInteractive: true,
      isLoop: true,
      storyPrompt: story.join('. '),
      imagePrompt: "",
      systemPrompt: "",
      synopsis: story.join('. '),
      bpm: 120,
      frameRate: 24,
    }
  })

  let startTimeInMs = 0
  let endTimeInMs = defaultSegmentDurationInMs

  if (showIntroPoweredByEngine) {
    clap.segments.push(newSegment({
      startTimeInMs,
      endTimeInMs,
      category: ClapSegmentCategory.INTERFACE,
      prompt: "<BUILTIN:POWERED_BY_ENGINE>",
      label: "disclaimer",
      outputType: ClapOutputType.INTERFACE,
    }))
    startTimeInMs += defaultSegmentDurationInMs
    endTimeInMs += defaultSegmentDurationInMs
  }

  if (showIntroDisclaimerAboutAI) {
    clap.segments.push(newSegment({
      startTimeInMs,
      endTimeInMs,
      category:ClapSegmentCategory.INTERFACE,
      prompt: "<BUILTIN:DISCLAIMER_ABOUT_AI>",
      label: "disclaimer",
      outputType: ClapOutputType.INTERFACE,
    }))
    startTimeInMs += defaultSegmentDurationInMs
    endTimeInMs += defaultSegmentDurationInMs
  }

  /*
  clap.segments.push(
    newSegment({
      // id: string
      // track: number
      startTimeInMs,
      endTimeInMs,
      category: ClapSegmentCategory.INTERFACE,
      // entityId: string
      // sceneId: string
      prompt: "a hello world",
      label: "hello world",
      outputType: ClapOutputType.INTERFACE,
      // renderId: string
      // status: ClapSegmentStatus
      // assetUrl: string
      // assetDurationInMs: number
      // createdBy: ClapAuthor
      // editedBy: ClapAuthor
      // outputGain: number
      // seed: number
    })
  )
    startTimeInMs += defaultSegmentDurationInMs
    endTimeInMs += defaultSegmentDurationInMs
  */
  
 

  for (let prompt of story) {
    /*
    clap.segments.push(newSegment({
      track: 0,
      startTimeInMs,
      endTimeInMs,
      category: ClapSegmentCategory.VIDEO,
      prompt: "",
      label: "video",
      outputType: ClapOutputType.VIDEO,
    }))
      */
    clap.segments.push(newSegment({
      track: 0,
      startTimeInMs,
      endTimeInMs,
      category: ClapSegmentCategory.IMAGE,
      prompt: "",
      label: "movie screencap",
      outputType: ClapOutputType.IMAGE,
    }))
    clap.segments.push(newSegment({
      track: 1,
      startTimeInMs,
      endTimeInMs,
      category: ClapSegmentCategory.GENERIC,
      prompt,
      label: prompt,
      outputType: ClapOutputType.TEXT,
    }))
    clap.segments.push(newSegment({
      track: 2,
      startTimeInMs,
      endTimeInMs,
      category: ClapSegmentCategory.CAMERA,
      prompt: "medium-shot",
      label: "medium-shot",
      outputType: ClapOutputType.TEXT,
    }))

    startTimeInMs += defaultSegmentDurationInMs
    endTimeInMs += defaultSegmentDurationInMs
  }

  clap.meta.durationInMs = endTimeInMs

  return clap
}