vikit.gateways.replicate_gateway

Overview

Classes

ReplicateGateway

A class to represent the Replicate Gateway, a gateway to the Replicate API

Classes

class vikit.gateways.replicate_gateway.ReplicateGateway

Bases: vikit.gateways.ML_models_gateway.MLModelsGateway

A class to represent the Replicate Gateway, a gateway to the Replicate API

Replicate is a platform that allows to run AI models in the cloud

Overview

Methods

compose_music_from_text_async(prompt_text, duration)

Compose a music for a prompt text

generate_background_music_async(duration, prompt, target_file_name)

Here we generate the music to add as background music

generate_seine_transition_async(source_image_path, target_image_path)

Generate a transition between two videos

generate_video_async(prompt, model_provider, prompt_image, aspect_ratio)

Generate a video from the given prompt

get_enhanced_prompt_async(subtitleText)

Generates an enhanced prompt from an original one, probably written by a user or

get_keywords_from_prompt_async(subtitleText, excluded_words)

Generates keywords from a subtitle text using the Replicate API.

get_music_generation_keywords_async(text)

Generate keywords from a text using the Replicate API

get_subtitles_async(audiofile_path)

Extract subtitles from an audio file using the Replicate API

interpolate_async(video)

Run some interpolation magic. This model may fail after timeout, so you

Members

async compose_music_from_text_async(prompt_text: str, duration: int)

Compose a music for a prompt text

Parameters:
  • prompt_text -- The text prompt

  • duration -- The duration of the music

Returns:

The link to the generated music

async generate_background_music_async(duration: int = 3, prompt: str = None, target_file_name: str = None) str

Here we generate the music to add as background music

Parameters:
  • duration -- int - the duration of the music in seconds

  • prompt -- str - the prompt to generate the music from

  • target_file_name -- str - the name of the file to save the music to

Returns:

the path to the generated music

Return type:

str

async generate_seine_transition_async(source_image_path, target_image_path)

Generate a transition between two videos

Parameters:
  • index -- The index of the video

  • initial -- Whether this is the initial video

Returns:

The link to the generated video

async generate_video_async(prompt, model_provider: str = 'videocrafter', prompt_image: str = '', aspect_ratio=(16, 9))

Generate a video from the given prompt

Parameters:

prompt -- The prompt to generate the video from

Returns:

the video

async get_enhanced_prompt_async(subtitleText)

Generates an enhanced prompt from an original one, probably written by a user or translated from an audio

Parameters:

subtitleText -- The original prompt

Returns:

A white space separated string of keywords composing the enhanced prompt

async get_keywords_from_prompt_async(subtitleText, excluded_words: str = None)

Generates keywords from a subtitle text using the Replicate API.

Parameters:

text (A subtitle)

Returns:

A white space separated string of keywords

async get_music_generation_keywords_async(text) str

Generate keywords from a text using the Replicate API

At the end of the resulting prompt we get 3 words that will be used to generate a file name out of the generated keywords

Parameters:

text -- The text to generate keywords from

Returns:

A list of keywords

async get_subtitles_async(audiofile_path)

Extract subtitles from an audio file using the Replicate API

Parameters:

i (int) -- The index of the audio slice

Returns:

The subtitles obtained from the Replicate API

Return type:

subs

async interpolate_async(video)

Run some interpolation magic. This model may fail after timeout, so you should call it with retry logic

Parameters:

video -- The video to interpolate

Returns:

a link to the interpolated video

Attributes

vikit.gateways.replicate_gateway.KEYWORDS_FORMAT_PROMPT = Multiline-String
Show Value
"""' Just list the keywords in english language, separated by a coma, do not re-output the prompt.
            The answer should be a list of keywords and exactly match the following format:  'KEYWORD1, KEYWORD2, KEYWORD3, etc'
            where KEYWORD1 and the other ones are generated by you.
            The last word of your answer should be a summary of all the other keywords so I can generate a file name
            out of it, it should be limited to three words joined by the underscore character and you should only use
            characters compatible with filenames in the summary, so only standard alphanumerical characters. Don't prefix the
            summary with any special characters, just the words joined by underscores.'"""