MuhammadSajid commited on
Commit
8054f81
·
verified ·
1 Parent(s): 4863ae7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -7,7 +7,8 @@ import os
7
  import subprocess
8
  from PIL import Image, ImageDraw, ImageFont
9
  import random
10
- import textwrap # Import the textwrap module
 
11
 
12
  # === Config ===
13
  GROQ_API_KEY = "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"
@@ -108,6 +109,14 @@ def create_basic_animation(text, audio_file):
108
  font_size = 24
109
  font = ImageFont.truetype("DejaVuSans.ttf", font_size) # Use a default font
110
 
 
 
 
 
 
 
 
 
111
  # 2. Create frames
112
  frames = []
113
  for i in range(num_frames):
@@ -153,7 +162,6 @@ def create_animation(text, audio_file):
153
  Selects and runs an animation function. This could be expanded to select from multiple animation styles.
154
  """
155
  # For now, just use the basic animation. You can add logic here to choose different animations.
156
- # return create_static_image_animation(text, audio_file)
157
  return create_basic_animation(text, audio_file)
158
 
159
  def process_audio(audio_file):
 
7
  import subprocess
8
  from PIL import Image, ImageDraw, ImageFont
9
  import random
10
+ import textwrap
11
+ import pkg_resources # Import pkg_resources
12
 
13
  # === Config ===
14
  GROQ_API_KEY = "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"
 
109
  font_size = 24
110
  font = ImageFont.truetype("DejaVuSans.ttf", font_size) # Use a default font
111
 
112
+ # 2. Check Pillow version
113
+ try:
114
+ pillow_version = pkg_resources.get_distribution("Pillow").version
115
+ if tuple(map(int, pillow_version.split("."))) < (8, 0, 0):
116
+ raise ImportError(f"Pillow version >= 8.0.0 is required, but found {pillow_version}")
117
+ except pkg_resources.DistributionNotFound:
118
+ raise ImportError("Pillow is not installed")
119
+
120
  # 2. Create frames
121
  frames = []
122
  for i in range(num_frames):
 
162
  Selects and runs an animation function. This could be expanded to select from multiple animation styles.
163
  """
164
  # For now, just use the basic animation. You can add logic here to choose different animations.
 
165
  return create_basic_animation(text, audio_file)
166
 
167
  def process_audio(audio_file):