wedyanessam commited on
Commit
5223b6a
·
verified ·
1 Parent(s): d54f0d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -14
app.py CHANGED
@@ -1,14 +1,14 @@
1
-
2
- chmod +x setup.sh && ./setup.sh
3
-
4
- import sys
5
  import os
6
- sys.path.append(os.path.abspath("."))
7
-
8
- import gradio as gr
9
  from pathlib import Path
10
  import argparse
 
11
 
 
 
 
 
 
12
 
13
  # استيراد بقية الأشياء
14
  from STT.sst import speech_to_text
@@ -18,9 +18,9 @@ from FantasyTalking.infer import load_models, main
18
 
19
  # ثابتات تحميل النموذج
20
  args_template = argparse.Namespace(
21
- wan_model_dir="./models/Wan2.1-I2V-14B-720P",
22
- fantasytalking_model_path="./models/fantasytalking_model.ckpt",
23
- wav2vec_model_dir="./models/wav2vec2-base-960h",
24
  image_path="",
25
  audio_path="",
26
  prompt="",
@@ -37,7 +37,9 @@ args_template = argparse.Namespace(
37
  )
38
 
39
  # تحميل النماذج مرة وحدة فقط
 
40
  pipe, fantasytalking, wav2vec_processor, wav2vec = load_models(args_template)
 
41
 
42
  def generate_video(image_path, audio_path, prompt, output_dir="./output"):
43
  args = argparse.Namespace(
@@ -50,16 +52,16 @@ def generate_video(image_path, audio_path, prompt, output_dir="./output"):
50
  return main(args, pipe, fantasytalking, wav2vec_processor, wav2vec)
51
 
52
  def full_pipeline(user_audio, user_image):
53
- # 1. تحويل الصوت إلى نص
54
  user_text = speech_to_text(user_audio)
55
 
56
- # 2. توليد الرد من LLM
57
  reply = generate_reply(user_text)
58
 
59
- # 3. تحويل الرد إلى صوت
60
  reply_audio_path = generate_voice(reply)
61
 
62
- # 4. توليد فيديو من الصورة والصوت
63
  Path("./output").mkdir(parents=True, exist_ok=True)
64
  video_path = generate_video(
65
  image_path=user_image,
 
 
 
 
 
1
  import os
2
+ import sys
 
 
3
  from pathlib import Path
4
  import argparse
5
+ import gradio as gr
6
 
7
+ # تشغيل سكربت التحميل إذا كنتِ تبغي تنفذيه هنا
8
+ os.system("chmod +x setup.sh && ./setup.sh")
9
+
10
+ # إعداد المسارات
11
+ sys.path.append(os.path.abspath("."))
12
 
13
  # استيراد بقية الأشياء
14
  from STT.sst import speech_to_text
 
18
 
19
  # ثابتات تحميل النموذج
20
  args_template = argparse.Namespace(
21
+ wan_model_dir="./wan", # افترضي إنك حملتيه هناك
22
+ fantasytalking_model_path="./fantasy/fantasytalking_model.ckpt",
23
+ wav2vec_model_dir="./wav2vec",
24
  image_path="",
25
  audio_path="",
26
  prompt="",
 
37
  )
38
 
39
  # تحميل النماذج مرة وحدة فقط
40
+ print("🚀 جاري تحميل النماذج...")
41
  pipe, fantasytalking, wav2vec_processor, wav2vec = load_models(args_template)
42
+ print("✅ تم تحميل النماذج بنجاح!")
43
 
44
  def generate_video(image_path, audio_path, prompt, output_dir="./output"):
45
  args = argparse.Namespace(
 
52
  return main(args, pipe, fantasytalking, wav2vec_processor, wav2vec)
53
 
54
  def full_pipeline(user_audio, user_image):
55
+ print("🎤 تحويل الصوت إلى نص...")
56
  user_text = speech_to_text(user_audio)
57
 
58
+ print("💬 توليد الرد...")
59
  reply = generate_reply(user_text)
60
 
61
+ print("🔊 تحويل الرد إلى صوت...")
62
  reply_audio_path = generate_voice(reply)
63
 
64
+ print("📽️ توليد الفيديو...")
65
  Path("./output").mkdir(parents=True, exist_ok=True)
66
  video_path = generate_video(
67
  image_path=user_image,