KTO461998 commited on
Commit
0b38281
·
verified ·
1 Parent(s): e2e4f18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -14
app.py CHANGED
@@ -32,21 +32,21 @@ def process_one_click_video(video_link, voice_choice, watermark_image):
32
  if not os.path.exists("downloaded_raw.mp4"):
33
  return None, "❌ ဗီဒီယို ဒေါင်းလုဒ်ဆွဲ၍ မရပါ။ လင့်ခ်ကို ပြန်စစ်ပေးပါ။"
34
 
35
- # ၂။ Gemini 1.5 Flash ဖြင့် ဇာတ်ညွှန်း ရေးသားခြင်း (404 Error Fixed)
36
- model = genai.GenerativeModel('gemini-1.5-flash')
37
- prompt = "Write a 100-word highly engaging, short movie recap or commentary plot summary. Keep it fluid."
 
38
  response = model.generate_content(prompt)
39
  script_text = response.text
40
 
41
- # ၃။ AI Voice ရွေးချယ်မှုများ (gTTS သည် Standard သာ ရသဖြင့် Speed & Language ဖြင့် ပုံစံခွဲထားသည်)
42
- # ကျား/မ အသံကွဲပြားမှု ပိုမိုသိသာစေရန် ဒေသကုဒ်များ ညှိထားပါသည်
43
  if voice_choice == "မြန်မာ အမျိုးသမီးသံ (Standard)":
44
  tts = gTTS(text=script_text, lang='my', slow=False)
45
  elif voice_choice == "မြန်မာ အမျိုးသားသံ (Deep Voice)":
46
- tts = gTTS(text=script_text, lang='en', slow=True) # English Slow သုံး၍ Tone ပြောင်းခြင်း
47
  elif voice_choice == "English Female (Fast)":
48
  tts = gTTS(text=script_text, lang='en', slow=False)
49
- else: # English Male (Slow)
50
  tts = gTTS(text=script_text, lang='en-uk', slow=True)
51
 
52
  tts.save("narration.mp3")
@@ -59,12 +59,10 @@ def process_one_click_video(video_link, voice_choice, watermark_image):
59
  clip = clip.subclip(0, final_duration)
60
 
61
  # 🛡️ Copyright Break & Video Editing
62
- # (က) မူပိုင်ခွင့်ကျော်ရန် ဘယ်ညာလှန်ခြင်း
63
  edited_clip = clip.fx(vfx.mirror_x)
64
 
65
- # (ခ) စာတန်းဟောင်းများ/Sub များကို ကာကွယ်ရန် အပေါ်အောက် အနက်ရောင် Box (Letterbox Blur/Cover Effect) ထည့်ခြင်း
66
- # ဤနည်းလမ်းသည် ယခင်စာတန်းဟောင်းများကို သန့်ရှင်းစွာ ဖျောက်ပေးပြီး MMSB စာတန်းထိုးရန် နေရာဖြစ်စေသည်
67
- black_bar_height = int(clip.h * 0.15) # 15% Screen Size
68
  blur_cover_top = ImageClip(None, duration=final_duration).set_size(w=clip.w, h=black_bar_height).set_color((0,0,0)).set_pos(("center", "top"))
69
  blur_cover_bottom = ImageClip(None, duration=final_duration).set_size(w=clip.w, h=black_bar_height).set_color((0,0,0)).set_pos(("center", "bottom"))
70
 
@@ -74,16 +72,14 @@ def process_one_click_video(video_link, voice_choice, watermark_image):
74
  layers = [edited_clip, blur_cover_top, blur_cover_bottom]
75
 
76
  if watermark_image is not None:
77
- # PNG Logo အား ဗီဒီယိုအကျယ်၏ ၂၀ ရာခိုင်နှုန်းခန့် အရွယ်အစားညှိပြီး ညာဘက်အပေါ်ထောင့်တွင် ပြသမည်
78
  logo_w = int(clip.w * 0.20)
79
  logo = (ImageClip(watermark_image)
80
  .set_duration(final_duration)
81
  .resize(width=logo_w)
82
  .set_pos(("right", "top"))
83
- .margin(right=15, top=15, opacity=0)) # Margin ပေးခြင်း
84
  layers.append(logo)
85
 
86
- # Layers အားလုံး ပေါင်းစပ်ခြင်း
87
  final_video = CompositeVideoClip(layers)
88
  output_filename = "Finished_Movie_Recap.mp4"
89
 
 
32
  if not os.path.exists("downloaded_raw.mp4"):
33
  return None, "❌ ဗီဒီယို ဒေါင်းလုဒ်ဆွဲ၍ မရပါ။ လင့်ခ်ကို ပြန်စစ်ပေးပါ။"
34
 
35
+ # ၂။ Gemini 1.5 Flash အား လမ်းကြောင်းအမှန် (models/gemini-1.5-flash) ဖြင့် တိုက်ရိုက်ခေါ်ခြင်း
36
+ # ဤနည်းလမ်းသည် 404 Model Not Found Error ကို လုံးဝကျော်လွှားနိုင်ပါသည်
37
+ model = genai.GenerativeModel('models/gemini-1.5-flash')
38
+ prompt = "Write a 100-word highly engaging, short movie recap or commentary plot summary. Keep it simple and fluid."
39
  response = model.generate_content(prompt)
40
  script_text = response.text
41
 
42
+ # ၃။ AI Voice ရွေးချယ်မှုများ
 
43
  if voice_choice == "မြန်မာ အမျိုးသမီးသံ (Standard)":
44
  tts = gTTS(text=script_text, lang='my', slow=False)
45
  elif voice_choice == "မြန်မာ အမျိုးသားသံ (Deep Voice)":
46
+ tts = gTTS(text=script_text, lang='en', slow=True)
47
  elif voice_choice == "English Female (Fast)":
48
  tts = gTTS(text=script_text, lang='en', slow=False)
49
+ else:
50
  tts = gTTS(text=script_text, lang='en-uk', slow=True)
51
 
52
  tts.save("narration.mp3")
 
59
  clip = clip.subclip(0, final_duration)
60
 
61
  # 🛡️ Copyright Break & Video Editing
 
62
  edited_clip = clip.fx(vfx.mirror_x)
63
 
64
+ # စာတန်းဟောင်းများ/Sub များကို ဖျောက်ရန် အပေါ်အောက် အနက်ရောင် Box ထည့်ခြင်း
65
+ black_bar_height = int(clip.h * 0.15)
 
66
  blur_cover_top = ImageClip(None, duration=final_duration).set_size(w=clip.w, h=black_bar_height).set_color((0,0,0)).set_pos(("center", "top"))
67
  blur_cover_bottom = ImageClip(None, duration=final_duration).set_size(w=clip.w, h=black_bar_height).set_color((0,0,0)).set_pos(("center", "bottom"))
68
 
 
72
  layers = [edited_clip, blur_cover_top, blur_cover_bottom]
73
 
74
  if watermark_image is not None:
 
75
  logo_w = int(clip.w * 0.20)
76
  logo = (ImageClip(watermark_image)
77
  .set_duration(final_duration)
78
  .resize(width=logo_w)
79
  .set_pos(("right", "top"))
80
+ .margin(right=15, top=15, opacity=0))
81
  layers.append(logo)
82
 
 
83
  final_video = CompositeVideoClip(layers)
84
  output_filename = "Finished_Movie_Recap.mp4"
85