File size: 1,055 Bytes
a99b4ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f64828c
a99b4ac
f64828c
a99b4ac
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
import { client } from '@gradio/client'

import { getRandomInt } from "./generateSeed.mts"

const videoSpaceApiUrl = process.env.WEBTV_VIDEO_SPACE_API_URL

export const callZeroscope = async (prompt: string, options?: {
  seed: number;
  nbFrames: number;
  nbSteps: number;
}) => {
  const seed = options?.seed || getRandomInt()
  const nbFrames = options?.nbFrames || 24 // we can go up to 48 frames, but then upscaling quill require too much memory!
  const nbSteps = options?.nbSteps || 35

  const api = await client(videoSpaceApiUrl)

  const rawResponse = await api.predict('/run', [		
    prompt, // string  in 'Prompt' Textbox component		
    seed, // number (numeric value between 0 and 2147483647) in 'Seed' Slider component		
    nbFrames, // 24 // it is the nb of frames per seconds I think?
    nbSteps, // 10, (numeric value between 10 and 50) in 'Number of inference steps' Slider component
  ]) as any
  
  const { name } = rawResponse?.data?.[0]?.[0] as { name: string, orig_name: string }

  return `${videoSpaceApiUrl}/file=${name}`
}