Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def generate_script(prompt, custom_text=None):
|
|
| 48 |
if generator:
|
| 49 |
input_text = f"Generate a script for a video about '{prompt}'. Create a numbered list with short descriptions (max 20 words per item) for a top 10 related to the topic."
|
| 50 |
try:
|
| 51 |
-
result = generator(input_text, max_length=300, num_return_sequences=1, do_sample=True)[0]['generated_text']
|
| 52 |
return result.strip()
|
| 53 |
except Exception as e:
|
| 54 |
print(f"Error generating script: {e}")
|
|
@@ -137,8 +137,7 @@ def create_video(prompt, custom_text, music_file):
|
|
| 137 |
clip.close()
|
| 138 |
audio.close()
|
| 139 |
if music_file:
|
| 140 |
-
music.close()
|
| 141 |
-
final_clip.close()
|
| 142 |
os.remove(voice_file)
|
| 143 |
for i in range(len(video_urls)):
|
| 144 |
os.remove(f"temp_clip_{i}.mp4")
|
|
@@ -156,4 +155,4 @@ with gr.Blocks() as demo:
|
|
| 156 |
output = gr.Video(label="Video Generado")
|
| 157 |
submit.click(fn=create_video, inputs=[prompt, custom_text, music_file], outputs=output)
|
| 158 |
|
| 159 |
-
demo.launch()
|
|
|
|
| 48 |
if generator:
|
| 49 |
input_text = f"Generate a script for a video about '{prompt}'. Create a numbered list with short descriptions (max 20 words per item) for a top 10 related to the topic."
|
| 50 |
try:
|
| 51 |
+
result = generator(input_text, max_length=300, num_return_sequences=1, do_sample=True, truncation=True)[0]['generated_text']
|
| 52 |
return result.strip()
|
| 53 |
except Exception as e:
|
| 54 |
print(f"Error generating script: {e}")
|
|
|
|
| 137 |
clip.close()
|
| 138 |
audio.close()
|
| 139 |
if music_file:
|
| 140 |
+
music.close final_clip.close()
|
|
|
|
| 141 |
os.remove(voice_file)
|
| 142 |
for i in range(len(video_urls)):
|
| 143 |
os.remove(f"temp_clip_{i}.mp4")
|
|
|
|
| 155 |
output = gr.Video(label="Video Generado")
|
| 156 |
submit.click(fn=create_video, inputs=[prompt, custom_text, music_file], outputs=output)
|
| 157 |
|
| 158 |
+
demo.launch(share=True)
|