Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
|
| 2 |
-
chmod +x setup.sh && ./setup.sh
|
| 3 |
-
|
| 4 |
-
import sys
|
| 5 |
import os
|
| 6 |
-
sys
|
| 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="./
|
| 22 |
-
fantasytalking_model_path="./
|
| 23 |
-
wav2vec_model_dir="./
|
| 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 |
-
|
| 54 |
user_text = speech_to_text(user_audio)
|
| 55 |
|
| 56 |
-
|
| 57 |
reply = generate_reply(user_text)
|
| 58 |
|
| 59 |
-
|
| 60 |
reply_audio_path = generate_voice(reply)
|
| 61 |
|
| 62 |
-
|
| 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,
|