File size: 1,911 Bytes
568a01c
 
e91a011
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
568a01c
e91a011
568a01c
e91a011
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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()