Spaces:
Sleeping
Sleeping
Update app.py
#1
by
Ken3659029
- opened
app.py
CHANGED
|
@@ -91,17 +91,19 @@ Produce a single, continuous, structured description following all the above rul
|
|
| 91 |
|
| 92 |
|
| 93 |
# --- 3. The Main Workflow Function for Gradio ---
|
| 94 |
-
def generate_sfx(
|
| 95 |
"""
|
| 96 |
This single function runs your entire workflow.
|
| 97 |
-
Gradio will pass the user's uploaded video
|
| 98 |
"""
|
| 99 |
if not all([GOOGLE_API_KEY, ELEVENLABS_API_KEY, LLAMA_405B_KEY, llama_client]):
|
| 100 |
-
raise gr.Error("API keys are not configured
|
| 101 |
|
| 102 |
try:
|
| 103 |
-
# ---
|
| 104 |
-
|
|
|
|
|
|
|
| 105 |
except Exception as e:
|
| 106 |
raise gr.Error(f"Failed to read video file: {e}")
|
| 107 |
|
|
@@ -201,7 +203,7 @@ demo = gr.Interface(
|
|
| 201 |
fn=generate_sfx, # The main function to call
|
| 202 |
|
| 203 |
# Input component: A video uploader
|
| 204 |
-
inputs=gr.Video(label="Upload Your Video Clip"),
|
| 205 |
|
| 206 |
# Output components: A list matching the function's return values
|
| 207 |
outputs=[
|
|
|
|
| 91 |
|
| 92 |
|
| 93 |
# --- 3. The Main Workflow Function for Gradio ---
|
| 94 |
+
def generate_sfx(video_file_object):
|
| 95 |
"""
|
| 96 |
This single function runs your entire workflow.
|
| 97 |
+
Gradio will pass the user's uploaded video as a file object.
|
| 98 |
"""
|
| 99 |
if not all([GOOGLE_API_KEY, ELEVENLABS_API_KEY, LLAMA_405B_KEY, llama_client]):
|
| 100 |
+
raise gr.Error("API keys are not configured...")
|
| 101 |
|
| 102 |
try:
|
| 103 |
+
# --- THIS IS THE NEW, FIXED LINE ---
|
| 104 |
+
# We now read directly from the file object's path
|
| 105 |
+
with open(video_file_object.name, 'rb') as f:
|
| 106 |
+
video_bytes = f.read()
|
| 107 |
except Exception as e:
|
| 108 |
raise gr.Error(f"Failed to read video file: {e}")
|
| 109 |
|
|
|
|
| 203 |
fn=generate_sfx, # The main function to call
|
| 204 |
|
| 205 |
# Input component: A video uploader
|
| 206 |
+
inputs=gr.Video(label="Upload Your Video Clip", type="file"),
|
| 207 |
|
| 208 |
# Output components: A list matching the function's return values
|
| 209 |
outputs=[
|