Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,10 @@ import os
|
|
9 |
script_generator = pipeline("text-generation", model="gpt2")
|
10 |
|
11 |
# Function to generate a comedy script using GPT-2
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
from gtts import gTTS
|
17 |
import os
|
@@ -23,18 +24,21 @@ def text_to_speech(script):
|
|
23 |
return audio_file
|
24 |
|
25 |
|
26 |
-
|
27 |
-
|
|
|
|
|
28 |
clips = []
|
29 |
-
|
30 |
-
|
31 |
-
text_clip =
|
|
|
32 |
clips.append(text_clip)
|
33 |
|
34 |
-
|
35 |
-
|
|
|
36 |
|
37 |
-
return output_video_file
|
38 |
|
39 |
import numpy as np
|
40 |
from scipy.io.wavfile import write
|
|
|
9 |
script_generator = pipeline("text-generation", model="gpt2")
|
10 |
|
11 |
# Function to generate a comedy script using GPT-2
|
12 |
+
from transformers import pipeline
|
13 |
+
|
14 |
+
script_generator = pipeline("text-generation", model="gpt2", truncation=True, max_length=100) # Adjust max_length as needed
|
15 |
+
|
16 |
|
17 |
from gtts import gTTS
|
18 |
import os
|
|
|
24 |
return audio_file
|
25 |
|
26 |
|
27 |
+
from moviepy.editor import TextClip
|
28 |
+
|
29 |
+
def generate_animation(script):
|
30 |
+
lines = script.split('\n')
|
31 |
clips = []
|
32 |
+
|
33 |
+
for line in lines:
|
34 |
+
text_clip = TextClip(line, fontsize=40, color='white', size=(800, 400), bg_color='black', method='caption', print_cmd=True)
|
35 |
+
text_clip = text_clip.set_duration(3) # Set duration for each clip
|
36 |
clips.append(text_clip)
|
37 |
|
38 |
+
# Concatenate all text clips into one video clip
|
39 |
+
final_video = concatenate_videoclips(clips)
|
40 |
+
return final_video
|
41 |
|
|
|
42 |
|
43 |
import numpy as np
|
44 |
from scipy.io.wavfile import write
|