Spaces:
Runtime error
Runtime error
import gradio as gr | |
def generate_videos(prompt, models, seed, video_duration): | |
""" | |
This function generates videos with audio from Audioldm using the Hugging Face website space and Gradio. | |
Parameters: | |
prompt (str): The text prompt for generating the videos. | |
models (list): The list of models to choose from (e.g., ["MODELSCOPE", "ZEROSCOPE"]). | |
seed (int): The seed number for generating different videos. | |
video_duration (int): The time duration of the video in seconds (between 2 and 60). | |
Returns: | |
str: The generated video with audio from Audioldm. | |
""" | |
try: | |
# Check if prompt is provided | |
if not prompt: | |
raise ValueError("Prompt is required") | |
# Check if models are provided | |
if not models: | |
raise ValueError("Models are required") | |
# Check if seed is within the valid range | |
if seed < -1 or seed > 1000000: | |
raise ValueError("Seed must be between -1 and 1000000") | |
# Check if video duration is within the valid range | |
if video_duration < 2 or video_duration > 60: | |
raise ValueError("Video duration must be between 2 and 60 seconds") | |
# Generate the videos using the provided inputs | |
# Add your code here | |
return "Generated video with audio from Audioldm" | |
except ValueError as e: | |
# Log the error | |
print(f"Error: {e}") | |
return "" | |
# Create the Gradio interface | |
inputs = [ | |
gr.inputs.Textbox(label="Prompt"), | |
gr.inputs.CheckboxGroup(["MODELSCOPE", "ZEROSCOPE"], label="Models"), | |
gr.inputs.Number(label="Seed", min_value=-1, max_value=1000000), | |
gr.inputs.Number(label="Video Duration", min_value=2, max_value=60) | |
] | |
output = gr.outputs.Textbox(label="Generated Video") | |
gr.Interface(fn=generate_videos, inputs=inputs, outputs=output).launch() |