Spaces:
Running
Running
prithivMLmods
commited on
Commit
•
f6c2653
1
Parent(s):
7b5d347
Update app.py
Browse files
app.py
CHANGED
@@ -36,8 +36,8 @@ def create_typing_video(code_text, format_choice, line_spacing, width_choice, he
|
|
36 |
# Adjust font size if necessary to fit text within image height
|
37 |
def adjust_font_size(text, font, max_width, max_height):
|
38 |
while True:
|
39 |
-
wrapped_lines = textwrap.wrap(text, width=max_width // font.
|
40 |
-
text_height = sum(font.
|
41 |
|
42 |
if text_height <= max_height:
|
43 |
return font
|
@@ -53,7 +53,7 @@ def create_typing_video(code_text, format_choice, line_spacing, width_choice, he
|
|
53 |
current_text += char
|
54 |
|
55 |
if format_choice == "Paragraph":
|
56 |
-
wrapped_lines = textwrap.wrap(current_text, width=max_width // font.
|
57 |
else: # Programming
|
58 |
wrapped_lines = current_text.splitlines()
|
59 |
|
@@ -64,7 +64,7 @@ def create_typing_video(code_text, format_choice, line_spacing, width_choice, he
|
|
64 |
y_position = 20
|
65 |
for line in wrapped_lines:
|
66 |
draw.text((20, y_position), line, font=font, fill=text_color)
|
67 |
-
line_height = font.
|
68 |
y_position += line_height * line_spacing
|
69 |
|
70 |
# Convert to numpy array for OpenCV
|
@@ -219,12 +219,11 @@ sound_choice = gr.Dropdown(
|
|
219 |
label="Typing Sound"
|
220 |
)
|
221 |
custom_audio = gr.File(
|
222 |
-
label="Upload Custom Audio SFX
|
223 |
-
type="filepath"
|
224 |
)
|
225 |
|
226 |
background_color = gr.Dropdown(
|
227 |
-
choices=["black", "white", "
|
228 |
value="black",
|
229 |
label="Background Color"
|
230 |
)
|
|
|
36 |
# Adjust font size if necessary to fit text within image height
|
37 |
def adjust_font_size(text, font, max_width, max_height):
|
38 |
while True:
|
39 |
+
wrapped_lines = textwrap.wrap(text, width=max_width // font.getbbox(' ')[2])
|
40 |
+
text_height = sum(font.getbbox(line)[3] - font.getbbox(line)[1] for line in wrapped_lines)
|
41 |
|
42 |
if text_height <= max_height:
|
43 |
return font
|
|
|
53 |
current_text += char
|
54 |
|
55 |
if format_choice == "Paragraph":
|
56 |
+
wrapped_lines = textwrap.wrap(current_text, width=max_width // font.getbbox(' ')[2])
|
57 |
else: # Programming
|
58 |
wrapped_lines = current_text.splitlines()
|
59 |
|
|
|
64 |
y_position = 20
|
65 |
for line in wrapped_lines:
|
66 |
draw.text((20, y_position), line, font=font, fill=text_color)
|
67 |
+
line_height = font.getbbox(line)[3] - font.getbbox(line)[1]
|
68 |
y_position += line_height * line_spacing
|
69 |
|
70 |
# Convert to numpy array for OpenCV
|
|
|
219 |
label="Typing Sound"
|
220 |
)
|
221 |
custom_audio = gr.File(
|
222 |
+
label="Upload Custom Audio SFX (Optional)"
|
|
|
223 |
)
|
224 |
|
225 |
background_color = gr.Dropdown(
|
226 |
+
choices=["black", "white", "gray", "blue", "green", "red"],
|
227 |
value="black",
|
228 |
label="Background Color"
|
229 |
)
|