Spaces:
Running
Running
Commit
·
d4a1dc1
1
Parent(s):
db70195
fix space crash
Browse files- src/app/api/v1/create/index.ts +6 -6
- src/app/api/v1/edit/dialogues/route.ts +2 -2
- src/app/api/v1/edit/entities/clapToLatentStory.ts +1 -1
- src/app/api/v1/edit/entities/generateEntityPrompts.ts +9 -3
- src/app/api/v1/edit/entities/index.ts +2 -2
- src/app/api/v1/edit/storyboards/route.ts +2 -2
- src/app/api/v1/edit/videos/processShot.ts +1 -1
- src/app/api/v1/edit/videos/route.ts +2 -2
src/app/api/v1/create/index.ts
CHANGED
@@ -147,20 +147,20 @@ Output: `
|
|
147 |
track: 2,
|
148 |
startTimeInMs: currentElapsedTimeInMs,
|
149 |
assetDurationInMs: defaultSegmentDurationInMs,
|
150 |
-
category:
|
151 |
prompt: title,
|
152 |
// assetUrl: `data:text/plain;base64,${btoa(title)}`,
|
153 |
assetUrl: title,
|
154 |
-
outputType:
|
155 |
}))
|
156 |
|
157 |
clap.segments.push(newSegment({
|
158 |
track: 3,
|
159 |
startTimeInMs: currentElapsedTimeInMs,
|
160 |
assetDurationInMs: defaultSegmentDurationInMs,
|
161 |
-
category:
|
162 |
prompt: voice,
|
163 |
-
outputType:
|
164 |
}))
|
165 |
|
166 |
// the presence of a camera is mandatory
|
@@ -168,9 +168,9 @@ Output: `
|
|
168 |
track: 4,
|
169 |
startTimeInMs: currentElapsedTimeInMs,
|
170 |
assetDurationInMs: defaultSegmentDurationInMs,
|
171 |
-
category:
|
172 |
prompt: "video",
|
173 |
-
outputType:
|
174 |
}))
|
175 |
|
176 |
currentElapsedTimeInMs += defaultSegmentDurationInMs
|
|
|
147 |
track: 2,
|
148 |
startTimeInMs: currentElapsedTimeInMs,
|
149 |
assetDurationInMs: defaultSegmentDurationInMs,
|
150 |
+
category: ClapSegmentCategory.INTERFACE,
|
151 |
prompt: title,
|
152 |
// assetUrl: `data:text/plain;base64,${btoa(title)}`,
|
153 |
assetUrl: title,
|
154 |
+
outputType: ClapOutputType.TEXT,
|
155 |
}))
|
156 |
|
157 |
clap.segments.push(newSegment({
|
158 |
track: 3,
|
159 |
startTimeInMs: currentElapsedTimeInMs,
|
160 |
assetDurationInMs: defaultSegmentDurationInMs,
|
161 |
+
category: ClapSegmentCategory.DIALOGUE,
|
162 |
prompt: voice,
|
163 |
+
outputType: ClapOutputType.AUDIO,
|
164 |
}))
|
165 |
|
166 |
// the presence of a camera is mandatory
|
|
|
168 |
track: 4,
|
169 |
startTimeInMs: currentElapsedTimeInMs,
|
170 |
assetDurationInMs: defaultSegmentDurationInMs,
|
171 |
+
category: ClapSegmentCategory.CAMERA,
|
172 |
prompt: "video",
|
173 |
+
outputType: ClapOutputType.TEXT,
|
174 |
}))
|
175 |
|
176 |
currentElapsedTimeInMs += defaultSegmentDurationInMs
|
src/app/api/v1/edit/dialogues/route.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import { NextResponse, NextRequest } from "next/server"
|
2 |
|
3 |
-
import { ClapProject, ClapSegment, newClap, parseClap, serializeClap } from "@aitube/clap"
|
4 |
|
5 |
|
6 |
import { processShot } from "./processShot"
|
@@ -28,7 +28,7 @@ export async function POST(req: NextRequest) {
|
|
28 |
|
29 |
console.log(`[api/edit/dialogues] detected ${existingClap.segments.length} segments`)
|
30 |
|
31 |
-
const shotsSegments: ClapSegment[] = existingClap.segments.filter(s => s.category ===
|
32 |
console.log(`[api/edit/dialogues] detected ${shotsSegments.length} shots`)
|
33 |
|
34 |
if (shotsSegments.length > 32) {
|
|
|
1 |
import { NextResponse, NextRequest } from "next/server"
|
2 |
|
3 |
+
import { ClapProject, ClapSegment, ClapSegmentCategory, newClap, parseClap, serializeClap } from "@aitube/clap"
|
4 |
|
5 |
|
6 |
import { processShot } from "./processShot"
|
|
|
28 |
|
29 |
console.log(`[api/edit/dialogues] detected ${existingClap.segments.length} segments`)
|
30 |
|
31 |
+
const shotsSegments: ClapSegment[] = existingClap.segments.filter(s => s.category === ClapSegmentCategory.CAMERA)
|
32 |
console.log(`[api/edit/dialogues] detected ${shotsSegments.length} shots`)
|
33 |
|
34 |
if (shotsSegments.length > 32) {
|
src/app/api/v1/edit/entities/clapToLatentStory.ts
CHANGED
@@ -11,7 +11,7 @@ import { LatentStory } from "@/app/api/v1/types"
|
|
11 |
* @returns
|
12 |
*/
|
13 |
export async function clapToLatentStory(clap: ClapProject): Promise<LatentStory[]> {
|
14 |
-
const shots = clap.segments.filter(s => s.category ===
|
15 |
|
16 |
const latentStories: LatentStory[] = []
|
17 |
|
|
|
11 |
* @returns
|
12 |
*/
|
13 |
export async function clapToLatentStory(clap: ClapProject): Promise<LatentStory[]> {
|
14 |
+
const shots = clap.segments.filter(s => s.category === ClapSegmentCategory.CAMERA)
|
15 |
|
16 |
const latentStories: LatentStory[] = []
|
17 |
|
src/app/api/v1/edit/entities/generateEntityPrompts.ts
CHANGED
@@ -21,13 +21,16 @@ export type EntityPromptResult = {
|
|
21 |
// this is mostly used by external apps such as the Stories Factory
|
22 |
export async function generateEntityPrompts({
|
23 |
prompt = "",
|
24 |
-
latentStory = []
|
|
|
25 |
}: {
|
26 |
prompt?: string
|
27 |
latentStory?: LatentStory[]
|
|
|
28 |
} = {
|
29 |
prompt: "",
|
30 |
-
latentStory: []
|
|
|
31 |
}): Promise<EntityPromptResult[]> {
|
32 |
|
33 |
if (!prompt.length) { throw new Error(`please provide a prompt`) }
|
@@ -66,6 +69,7 @@ Now please generate the output entities:`
|
|
66 |
userPrompt,
|
67 |
nbMaxNewTokens,
|
68 |
prefix,
|
|
|
69 |
})
|
70 |
|
71 |
console.log("generateEntityPrompts(): rawString: ", rawString)
|
@@ -84,6 +88,7 @@ Now please generate the output entities:`
|
|
84 |
userPrompt: userPrompt + ".", // we trick the Hugging Face cache
|
85 |
nbMaxNewTokens,
|
86 |
prefix,
|
|
|
87 |
})
|
88 |
|
89 |
console.log("generateEntityPrompts(): rawString: ", rawString)
|
@@ -111,7 +116,8 @@ Now please generate the output entities:`
|
|
111 |
region: "",
|
112 |
identityImage: await generateImageID({
|
113 |
prompt: image,
|
114 |
-
seed: generateSeed()
|
|
|
115 |
}),
|
116 |
|
117 |
// TODO later
|
|
|
21 |
// this is mostly used by external apps such as the Stories Factory
|
22 |
export async function generateEntityPrompts({
|
23 |
prompt = "",
|
24 |
+
latentStory = [],
|
25 |
+
turbo = false,
|
26 |
}: {
|
27 |
prompt?: string
|
28 |
latentStory?: LatentStory[]
|
29 |
+
turbo?: boolean
|
30 |
} = {
|
31 |
prompt: "",
|
32 |
+
latentStory: [],
|
33 |
+
turbo: false
|
34 |
}): Promise<EntityPromptResult[]> {
|
35 |
|
36 |
if (!prompt.length) { throw new Error(`please provide a prompt`) }
|
|
|
69 |
userPrompt,
|
70 |
nbMaxNewTokens,
|
71 |
prefix,
|
72 |
+
turbo,
|
73 |
})
|
74 |
|
75 |
console.log("generateEntityPrompts(): rawString: ", rawString)
|
|
|
88 |
userPrompt: userPrompt + ".", // we trick the Hugging Face cache
|
89 |
nbMaxNewTokens,
|
90 |
prefix,
|
91 |
+
turbo,
|
92 |
})
|
93 |
|
94 |
console.log("generateEntityPrompts(): rawString: ", rawString)
|
|
|
116 |
region: "",
|
117 |
identityImage: await generateImageID({
|
118 |
prompt: image,
|
119 |
+
seed: generateSeed(),
|
120 |
+
turbo,
|
121 |
}),
|
122 |
|
123 |
// TODO later
|
src/app/api/v1/edit/entities/index.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
|
2 |
-
import { ClapProject, getClapAssetSourceType, getValidNumber, newEntity } from "@aitube/clap"
|
3 |
import { ClapCompletionMode, ClapEntityPrompt } from "@aitube/client"
|
4 |
|
5 |
import { generateImageID } from "./generateImageID"
|
@@ -39,7 +39,7 @@ export async function editEntities({
|
|
39 |
turbo,
|
40 |
})
|
41 |
|
42 |
-
const allShots = existingClap.segments.filter(s => s.category ===
|
43 |
|
44 |
for (const {
|
45 |
entityPrompt: { name, category, age, variant, region, identityImage, identityVoice },
|
|
|
1 |
|
2 |
+
import { ClapProject, ClapSegmentCategory, getClapAssetSourceType, getValidNumber, newEntity } from "@aitube/clap"
|
3 |
import { ClapCompletionMode, ClapEntityPrompt } from "@aitube/client"
|
4 |
|
5 |
import { generateImageID } from "./generateImageID"
|
|
|
39 |
turbo,
|
40 |
})
|
41 |
|
42 |
+
const allShots = existingClap.segments.filter(s => s.category === ClapSegmentCategory.CAMERA)
|
43 |
|
44 |
for (const {
|
45 |
entityPrompt: { name, category, age, variant, region, identityImage, identityVoice },
|
src/app/api/v1/edit/storyboards/route.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import { NextResponse, NextRequest } from "next/server"
|
2 |
import queryString from "query-string"
|
3 |
-
import { ClapProject, ClapSegment, newClap, parseClap, serializeClap } from "@aitube/clap"
|
4 |
|
5 |
import { parseCompletionMode } from "@/app/api/parsers/parseCompletionMode"
|
6 |
import { throwIfInvalidToken } from "@/app/api/v1/auth/throwIfInvalidToken"
|
@@ -33,7 +33,7 @@ export async function POST(req: NextRequest) {
|
|
33 |
|
34 |
console.log(`api/v1/edit/storyboards(): detected ${existingClap.segments.length} segments`)
|
35 |
|
36 |
-
const shotsSegments: ClapSegment[] = existingClap.segments.filter(s => s.category ===
|
37 |
console.log(`api/v1/edit/storyboards(): detected ${shotsSegments.length} shots`)
|
38 |
|
39 |
if (shotsSegments.length > 32) {
|
|
|
1 |
import { NextResponse, NextRequest } from "next/server"
|
2 |
import queryString from "query-string"
|
3 |
+
import { ClapProject, ClapSegment, ClapSegmentCategory, newClap, parseClap, serializeClap } from "@aitube/clap"
|
4 |
|
5 |
import { parseCompletionMode } from "@/app/api/parsers/parseCompletionMode"
|
6 |
import { throwIfInvalidToken } from "@/app/api/v1/auth/throwIfInvalidToken"
|
|
|
33 |
|
34 |
console.log(`api/v1/edit/storyboards(): detected ${existingClap.segments.length} segments`)
|
35 |
|
36 |
+
const shotsSegments: ClapSegment[] = existingClap.segments.filter(s => s.category === ClapSegmentCategory.CAMERA)
|
37 |
console.log(`api/v1/edit/storyboards(): detected ${shotsSegments.length} shots`)
|
38 |
|
39 |
if (shotsSegments.length > 32) {
|
src/app/api/v1/edit/videos/processShot.ts
CHANGED
@@ -87,7 +87,7 @@ export async function processShot({
|
|
87 |
shotVideoSegment.assetUrl = await generateVideo({
|
88 |
prompt: getPositivePrompt(shotVideoSegment.prompt),
|
89 |
width: existingClap.meta.width,
|
90 |
-
height: existingClap.meta.height
|
91 |
turbo,
|
92 |
})
|
93 |
shotVideoSegment.assetSourceType = getClapAssetSourceType(shotVideoSegment.assetUrl)
|
|
|
87 |
shotVideoSegment.assetUrl = await generateVideo({
|
88 |
prompt: getPositivePrompt(shotVideoSegment.prompt),
|
89 |
width: existingClap.meta.width,
|
90 |
+
height: existingClap.meta.height,
|
91 |
turbo,
|
92 |
})
|
93 |
shotVideoSegment.assetSourceType = getClapAssetSourceType(shotVideoSegment.assetUrl)
|
src/app/api/v1/edit/videos/route.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import { NextResponse, NextRequest } from "next/server"
|
2 |
import queryString from "query-string"
|
3 |
-
import { ClapProject, ClapSegment, newClap, parseClap, serializeClap } from "@aitube/clap"
|
4 |
import { ClapCompletionMode } from "@aitube/client"
|
5 |
|
6 |
import { parseCompletionMode } from "@/app/api/parsers/parseCompletionMode"
|
@@ -33,7 +33,7 @@ export async function POST(req: NextRequest) {
|
|
33 |
|
34 |
console.log(`api/edit/videos(): detected ${existingClap.segments.length} segments`)
|
35 |
|
36 |
-
const shotsSegments: ClapSegment[] = existingClap.segments.filter(s => s.category ===
|
37 |
console.log(`api/edit/videos(): detected ${shotsSegments.length} shots`)
|
38 |
|
39 |
if (shotsSegments.length > 32) {
|
|
|
1 |
import { NextResponse, NextRequest } from "next/server"
|
2 |
import queryString from "query-string"
|
3 |
+
import { ClapProject, ClapSegment, ClapSegmentCategory, newClap, parseClap, serializeClap } from "@aitube/clap"
|
4 |
import { ClapCompletionMode } from "@aitube/client"
|
5 |
|
6 |
import { parseCompletionMode } from "@/app/api/parsers/parseCompletionMode"
|
|
|
33 |
|
34 |
console.log(`api/edit/videos(): detected ${existingClap.segments.length} segments`)
|
35 |
|
36 |
+
const shotsSegments: ClapSegment[] = existingClap.segments.filter(s => s.category === ClapSegmentCategory.CAMERA)
|
37 |
console.log(`api/edit/videos(): detected ${shotsSegments.length} shots`)
|
38 |
|
39 |
if (shotsSegments.length > 32) {
|