Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,8 +17,12 @@ model = WhisperModel("small", device="cpu", compute_type="int8")
|
|
| 17 |
|
| 18 |
|
| 19 |
def process_arabic_text(text):
|
|
|
|
|
|
|
| 20 |
reshaped_text = reshape(text)
|
|
|
|
| 21 |
bidi_text = get_display(reshaped_text)
|
|
|
|
| 22 |
return bidi_text + "\n "
|
| 23 |
|
| 24 |
|
|
@@ -62,18 +66,19 @@ def step_2_render_video(video_path, df_edited):
|
|
| 62 |
|
| 63 |
clean_text = process_arabic_text(word_text)
|
| 64 |
|
| 65 |
-
|
| 66 |
-
# إنشاء النص بدون خلفية (Transparent Background)
|
| 67 |
txt_clip = TextClip(
|
| 68 |
text=clean_text,
|
| 69 |
-
font_size=
|
| 70 |
color='yellow',
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
stroke_width=2, # جعل الحدود أسمك لزيادة التباين
|
| 74 |
method='caption',
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
| 77 |
)
|
| 78 |
|
| 79 |
txt_clip = (txt_clip
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def process_arabic_text(text):
|
| 20 |
+
"""إصلاح الحروف العربية وتجهيزها للعرض الصحيح"""
|
| 21 |
+
# 1. إعادة تشكيل الحروف (توصيلها)
|
| 22 |
reshaped_text = reshape(text)
|
| 23 |
+
# 2. ضبط الاتجاه من اليمين لليسار
|
| 24 |
bidi_text = get_display(reshaped_text)
|
| 25 |
+
# 3. إضافة السطر الوهمي لمنع قص النقاط
|
| 26 |
return bidi_text + "\n "
|
| 27 |
|
| 28 |
|
|
|
|
| 66 |
|
| 67 |
clean_text = process_arabic_text(word_text)
|
| 68 |
|
| 69 |
+
# داخل دالة step_2_render_video، تأكد من إعداد TextClip هكذا:
|
|
|
|
| 70 |
txt_clip = TextClip(
|
| 71 |
text=clean_text,
|
| 72 |
+
font_size=70,
|
| 73 |
color='yellow',
|
| 74 |
+
stroke_color='black',
|
| 75 |
+
stroke_width=2,
|
|
|
|
| 76 |
method='caption',
|
| 77 |
+
font="arialbd.ttf", # تأكد أنك رفعت الملف بهذا الاسم
|
| 78 |
+
size=(int(w * 0.8), None),
|
| 79 |
+
text_align='center',
|
| 80 |
+
# إضافة هذا المعامل يضمن عدم تدخل MoviePy في ترتيب الحروف
|
| 81 |
+
interline=0
|
| 82 |
)
|
| 83 |
|
| 84 |
txt_clip = (txt_clip
|