juancopi81 commited on
Commit
cc7fff5
1 Parent(s): 25733b9

Add some example, reduce max num of tokens, add code to avoid error in video creation

Browse files
Files changed (3) hide show
  1. app.py +10 -0
  2. textprocessor.py +1 -1
  3. videocreator.py +17 -2
app.py CHANGED
@@ -210,6 +210,16 @@ with block as demo:
210
  <p style="margin-bottom: 10px; font-size: 94%">
211
  Running on <b>{device_print}</b>
212
  </p>
 
 
 
 
 
 
 
 
 
 
213
  </div>
214
  """
215
  )
 
210
  <p style="margin-bottom: 10px; font-size: 94%">
211
  Running on <b>{device_print}</b>
212
  </p>
213
+ <p>
214
+ Some samples videos you can try:
215
+ <ul>
216
+ <li>https://www.youtube.com/watch?v=sRmmQBBln9Q (Cook recipe. Infer time: c.a. 200 seconds)</li>
217
+ <li>https://www.youtube.com/watch?v=qz4Wc48KITA (Poem by Edgar Allan Poe. Infer time: c.a. 200 seconds)</li>
218
+ <li>https://www.youtube.com/watch?v=2D8CaoIY7Lk (The history of Christmas trees. Infer time: c.a. 130 seconds)</li>
219
+ <li>https://www.youtube.com/watch?v=uhmRR-Ir7Bk (Dec. 20 news. Infer time: c.a. 230 seconds)</li>
220
+ <li>https://www.youtube.com/watch?v=CT9T7Dp63x4 (Presentation of movie Lady Chatterley's Lover. Infer time: c.a. 277 seconds)</li>
221
+ </ul>
222
+ </p>
223
  </div>
224
  """
225
  )
textprocessor.py CHANGED
@@ -27,7 +27,7 @@ class TextProcessor:
27
  def __init__(self,
28
  model: str = "text-davinci-003",
29
  temperature: float = 0.7,
30
- max_tokens: int = 2500,
31
  top_p: int = 1,
32
  frequency_penalty: int = 0,
33
  presence_penalty: int = 0) -> None:
 
27
  def __init__(self,
28
  model: str = "text-davinci-003",
29
  temperature: float = 0.7,
30
+ max_tokens: int = 1240,
31
  top_p: int = 1,
32
  frequency_penalty: int = 0,
33
  presence_penalty: int = 0) -> None:
videocreator.py CHANGED
@@ -44,5 +44,20 @@ class VideoCreator:
44
  video_clip = VideoFileClip(videos_dict[video])
45
  videos_to_concatenate.append(video_clip)
46
  final_video = concatenate_videoclips(videos_to_concatenate)
47
- final_video.write_videofile("final_video.mp4")
48
- return "final_video.mp4"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  video_clip = VideoFileClip(videos_dict[video])
45
  videos_to_concatenate.append(video_clip)
46
  final_video = concatenate_videoclips(videos_to_concatenate)
47
+ try:
48
+ final_video.write_videofile("final_video.mp4",
49
+ threads=4,
50
+ logger=None)
51
+ print("Saved .mp4 without Exception at final_video.mp4")
52
+ return "final_video.mp4"
53
+ except IndexError:
54
+ # Short by one frame, so get rid on the last frame:
55
+ final_video = final_video.subclip(t_end=(video_clip.duration - 1.0/final_video.fps))
56
+ final_video.write_videofile("final_video.mp4",
57
+ threads=4,
58
+ logger=None)
59
+ print("Saved .mp4 after Exception at final_video.mp4")
60
+ return "final_video.mp4"
61
+ except Exception as e:
62
+ print("Exception {} was raised!!".format(e))
63
+ return "final_video.mp4"