-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
work on live generation and entity creation
- Loading branch information
1 parent
5114d57
commit 90d2096
Showing
18 changed files
with
447 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
'use client' | ||
|
||
import { | ||
clapSegmentToTimelineSegment, | ||
TimelineSegment, | ||
TimelineStore, | ||
useTimeline, | ||
} from '@aitube/timeline' | ||
import { | ||
ResolveRequest, | ||
ResolveRequestPrompts, | ||
SettingsStore, | ||
} from '@aitube/clapper-services' | ||
import { useSettings } from '../settings' | ||
import { ClapSegmentCategory, newSegment } from '@aitube/clap' | ||
import { getDefaultResolveRequestPrompts } from '../resolver/getDefaultResolveRequestPrompts' | ||
|
||
export async function resolve( | ||
req: Partial<ResolveRequest> | ||
): Promise<TimelineSegment> { | ||
const { getRequestSettings }: SettingsStore = useSettings.getState() | ||
const { meta }: TimelineStore = useTimeline.getState() | ||
|
||
const defaultTimelineSegment: TimelineSegment = | ||
await clapSegmentToTimelineSegment( | ||
newSegment({ | ||
category: ClapSegmentCategory.STORYBOARD, | ||
}) | ||
) | ||
|
||
const segment: TimelineSegment = { | ||
...defaultTimelineSegment, | ||
...req.segment, | ||
|
||
// we omit things that cannot be serialized | ||
scene: undefined, | ||
audioBuffer: undefined, | ||
textures: {}, | ||
} | ||
|
||
const request: ResolveRequest = { | ||
settings: getRequestSettings(), | ||
segment, | ||
|
||
segments: Array.isArray(req.segments) | ||
? req.segments.map((s) => ({ | ||
...s, | ||
|
||
// we omit things that cannot be serialized | ||
scene: undefined, | ||
audioBuffer: undefined, | ||
textures: {}, | ||
})) | ||
: [], | ||
|
||
entities: req.entities ? req.entities : {}, | ||
speakingCharactersIds: Array.isArray(req.speakingCharactersIds) | ||
? req.speakingCharactersIds | ||
: [], | ||
generalCharactersIds: Array.isArray(req.generalCharactersIds) | ||
? req.generalCharactersIds | ||
: [], | ||
mainCharacterId: req.mainCharacterId || undefined, | ||
mainCharacterEntity: req.mainCharacterEntity || undefined, | ||
meta, | ||
prompts: getDefaultResolveRequestPrompts(req.prompts), | ||
} | ||
|
||
const res = await fetch('/api/resolve', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(request), | ||
}) | ||
|
||
const newSegmentData = (await res.json()) as TimelineSegment | ||
|
||
return newSegmentData | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 30 additions & 1 deletion
31
packages/app/src/services/renderer/getDefaultRendererState.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/app/src/services/resolver/getDefaultResolveRequestPrompts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ResolveRequestPrompts } from '@aitube/clapper-services' | ||
|
||
type DeepPartial<T> = T extends object | ||
? { | ||
[P in keyof T]?: DeepPartial<T[P]> | ||
} | ||
: T | ||
|
||
export function getDefaultResolveRequestPrompts( | ||
partials: DeepPartial<ResolveRequestPrompts> = {} | ||
): ResolveRequestPrompts { | ||
const defaultPrompts: ResolveRequestPrompts = { | ||
image: { | ||
identity: `${partials?.image?.identity || ''}`, | ||
positive: `${partials?.image?.positive || ''}`, | ||
negative: `${partials?.image?.negative || ''}`, | ||
}, | ||
video: { | ||
image: `${partials?.video?.image || ''}`, | ||
voice: `${partials?.video?.voice || ''}`, | ||
}, | ||
voice: { | ||
identity: `${partials?.voice?.identity || ''}`, | ||
positive: `${partials?.voice?.positive || ''}`, | ||
negative: `${partials?.voice?.negative || ''}`, | ||
}, | ||
audio: { | ||
positive: `${partials?.audio?.positive || ''}`, | ||
negative: `${partials?.audio?.negative || ''}`, | ||
}, | ||
music: { | ||
positive: `${partials?.music?.positive || ''}`, | ||
negative: `${partials?.music?.negative || ''}`, | ||
}, | ||
} | ||
return defaultPrompts | ||
} |
Oops, something went wrong.