akhaliq HF Staff commited on
Commit
9e58195
·
verified ·
1 Parent(s): 68fd7ee

Update Gradio app with multiple files

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -101,21 +101,20 @@ def validate_api_key(api_key: str) -> bool:
101
  except:
102
  return False
103
 
104
-
 
 
 
105
 
106
  # Build the Gradio interface
107
  with gr.Blocks(title="Sora-2 Text-to-Video Generator", theme=gr.themes.Soft()) as demo:
108
  gr.HTML("""
109
  <div style="text-align: center; margin-bottom: 2rem;">
110
  <h1>🎬 Sora-2 Text-to-Video Generator</h1>
 
111
  </div>
112
  """)
113
 
114
- # Hidden inputs for default values
115
- api_key_input = gr.Textbox(value="", visible=False)
116
- duration_slider = gr.Slider(value=8, visible=False)
117
- size_dropdown = gr.Dropdown(value="1280x720", visible=False)
118
-
119
  prompt_input = gr.Textbox(
120
  label="Enter your prompt",
121
  placeholder="Describe the video you want to create...",
@@ -125,13 +124,12 @@ with gr.Blocks(title="Sora-2 Text-to-Video Generator", theme=gr.themes.Soft()) a
125
  generate_btn = gr.Button("Generate Video", variant="primary")
126
 
127
  video_output = gr.Video(label="Generated Video")
128
- status_output = gr.Textbox(label="Status", interactive=False, visible=False)
129
 
130
- # Event handlers
131
  generate_btn.click(
132
- fn=generate_video,
133
- inputs=[prompt_input, duration_slider, size_dropdown, api_key_input],
134
- outputs=[video_output, status_output]
135
  )
136
 
137
  # Launch the application
 
101
  except:
102
  return False
103
 
104
+ def simple_generate(prompt: str) -> Optional[str]:
105
+ """Simplified wrapper for generate_video that only takes prompt and returns video."""
106
+ video_path, _ = generate_video(prompt, duration=8, size="1280x720", api_key=None)
107
+ return video_path
108
 
109
  # Build the Gradio interface
110
  with gr.Blocks(title="Sora-2 Text-to-Video Generator", theme=gr.themes.Soft()) as demo:
111
  gr.HTML("""
112
  <div style="text-align: center; margin-bottom: 2rem;">
113
  <h1>🎬 Sora-2 Text-to-Video Generator</h1>
114
+ <p><a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank">Built with anycoder</a></p>
115
  </div>
116
  """)
117
 
 
 
 
 
 
118
  prompt_input = gr.Textbox(
119
  label="Enter your prompt",
120
  placeholder="Describe the video you want to create...",
 
124
  generate_btn = gr.Button("Generate Video", variant="primary")
125
 
126
  video_output = gr.Video(label="Generated Video")
 
127
 
128
+ # Event handler
129
  generate_btn.click(
130
+ fn=simple_generate,
131
+ inputs=prompt_input,
132
+ outputs=video_output
133
  )
134
 
135
  # Launch the application