Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
# دالة الصفحة الرئيسية
|
| 4 |
def home_page():
|
| 5 |
return """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
<h1>مرحباً بك في Wasm-Speeker</h1>
|
| 7 |
<p>Wasm-Speeker هو إطار متقدم يعتمد على تقنيات الذكاء الاصطناعي لتوليد الكلام من النصوص.</p>
|
| 8 |
<p>تعتمد جميع النماذج على بنية VITS، التي تتيح توليد موجات صوتية واقعية بناءً على المدخلات النصية.</p>
|
|
@@ -16,11 +72,53 @@ def home_page():
|
|
| 16 |
<li>الشعبية والانتشار.</li>
|
| 17 |
<li>حجم النموذج: 36.3 مليون باراميتر.</li>
|
| 18 |
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
"""
|
| 20 |
|
| 21 |
# دالة صفحة "Chat AI"
|
| 22 |
def chat_ai_service():
|
| 23 |
return """
|
|
|
|
| 24 |
<h2>خدمة Chat AI</h2>
|
| 25 |
<p>خدمة تفاعلية تستخدم تقنيات الذكاء الاصطناعي المتقدمة لتوليد ردود طبيعية وسلسة على الرسائل.</p>
|
| 26 |
<p>تتميز هذه الخدمة بالقدرة على فهم اللهجة السعودية واستخدامها في الردود.</p>
|
|
@@ -30,48 +128,108 @@ def chat_ai_service():
|
|
| 30 |
<li>التعامل مع النص والصوت.</li>
|
| 31 |
<li>تعدد الاستخدامات: خدمة العملاء، الترفيه، التعليم، التسويق.</li>
|
| 32 |
</ul>
|
|
|
|
| 33 |
"""
|
| 34 |
|
| 35 |
# دالة صفحة "خدمات الرد بالصوت السعودي"
|
| 36 |
def saudi_voice_service():
|
| 37 |
return """
|
|
|
|
| 38 |
<h2>خدمة الرد بالصوت السعودي</h2>
|
| 39 |
<p>توليد أصوات واقعية باللهجة السعودية.</p>
|
| 40 |
<p>الخدمة مثالية لتطبيقات مثل المساعدات الصوتية أو الردود التفاعلية بالصوت.</p>
|
|
|
|
| 41 |
"""
|
| 42 |
|
| 43 |
# دالة صفحة "تحويل النص إلى اللهجة السعودية"
|
| 44 |
def text_to_najdi_service():
|
| 45 |
return """
|
|
|
|
| 46 |
<h2>تحويل النص من العربية إلى اللهجة السعودية</h2>
|
| 47 |
<p>هذه الخدمة تقوم بتحويل النصوص القياسية المكتوبة باللغة العربية إلى اللهجة السعودية، مما يجعلها مثالية لتطبيقات مثل المساعدات الصوتية أو الأنظمة التعليمية.</p>
|
|
|
|
| 48 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
-
|
|
|
|
| 51 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# العنوان الرئيسي
|
| 53 |
gr.Markdown("# Wasm-Speeker: إطار الذكاء الاصطناعي لتوليد الكلام")
|
| 54 |
-
|
| 55 |
# عرض الصورة الترحيبية
|
| 56 |
-
gr.Image("9588e6d4-9959-4cfc-9697-fc9b996fcd97.jpeg", label="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
# تبويبات الصفحات
|
| 59 |
with gr.Tabs():
|
| 60 |
# صفحة رئيسية
|
| 61 |
with gr.TabItem("الصفحة الرئيسية"):
|
| 62 |
-
gr.HTML(home_page)
|
| 63 |
|
| 64 |
# صفحة خدمة Chat AI
|
| 65 |
-
with gr.TabItem("
|
| 66 |
-
gr.HTML(chat_ai_service)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
# صفحة خدمة الرد بالصوت السعودي
|
| 69 |
-
with gr.TabItem("
|
| 70 |
-
gr.HTML(saudi_voice_service)
|
| 71 |
|
| 72 |
# صفحة خدمة تحويل النص إلى اللهجة السعودية
|
| 73 |
-
with gr.TabItem("
|
| 74 |
-
gr.HTML(text_to_najdi_service)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
# تشغيل الموقع
|
| 77 |
-
demo.launch()
|
|
|
|
| 1 |
+
from gradio_client import Client
|
| 2 |
+
client = Client("wasmdashai/wasmdashai-vits-ar-sa-huba")
|
| 3 |
+
def get_wav(text,name_model="wasmdashai/vits-ar-sa-huba-v2"):
|
| 4 |
+
|
| 5 |
+
result = client.predict(
|
| 6 |
+
text=text,
|
| 7 |
+
name_model=name_model,
|
| 8 |
+
api_name="/predict"
|
| 9 |
+
)
|
| 10 |
+
return result
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
client_ai = Client("wasmdashai/wasm-speeker-sa")
|
| 14 |
+
def t2t(text):
|
| 15 |
+
result = client_ai.predict(
|
| 16 |
+
text=text,
|
| 17 |
+
api_name="/t2t"
|
| 18 |
+
)
|
| 19 |
+
return result
|
| 20 |
+
|
| 21 |
+
def modelspeech(text,name_model):
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
return get_wav(text,name_model)
|
| 27 |
+
|
| 28 |
+
def modelspeech_ai(text,name_model):
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
text=t2t(text)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
return modelspeech(text,name_model)
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
|
| 39 |
import gradio as gr
|
| 40 |
|
| 41 |
# دالة الصفحة الرئيسية
|
| 42 |
def home_page():
|
| 43 |
return """
|
| 44 |
+
<div class="px-4 py-5 my-5 text-center">
|
| 45 |
+
<img class="d-block mx-auto mb-4" src="/docs/5.0/assets/brand/bootstrap-logo.svg" alt="" width="72" height="57">
|
| 46 |
+
<h1 class="display-5 fw-bold">مرحباً بك في Wasm-Speeker</h1>
|
| 47 |
+
<div class="col-lg-6 mx-auto">
|
| 48 |
+
<p class="lead mb-4">
|
| 49 |
+
Wasm-Speeker هو إطار متقدم يعتمد على تقنيات الذكاء الاصطناعي لتوليد الكلام من النصوص.
|
| 50 |
+
|
| 51 |
+
تعتمد جميع النماذج على بنية VITS، التي تتيح توليد موجات صوتية واقعية بناءً على المدخلات النصية.
|
| 52 |
+
|
| 53 |
+
النماذج تحتوي على محولات لتحليل النص وتوليد الكلام بناءً على خصائص الصوت المحلية لكل لهجة.
|
| 54 |
+
</p>
|
| 55 |
+
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
|
| 56 |
+
<button type="button" class="btn btn-primary btn-lg px-4 gap-3">Primary button</button>
|
| 57 |
+
<button type="button" class="btn btn-outline-secondary btn-lg px-4">Secondary</button>
|
| 58 |
+
</div>
|
| 59 |
+
</div>
|
| 60 |
+
</div>
|
| 61 |
+
<div style='text-align: right; direction: rtl;'>
|
| 62 |
<h1>مرحباً بك في Wasm-Speeker</h1>
|
| 63 |
<p>Wasm-Speeker هو إطار متقدم يعتمد على تقنيات الذكاء الاصطناعي لتوليد الكلام من النصوص.</p>
|
| 64 |
<p>تعتمد جميع النماذج على بنية VITS، التي تتيح توليد موجات صوتية واقعية بناءً على المدخلات النصية.</p>
|
|
|
|
| 72 |
<li>الشعبية والانتشار.</li>
|
| 73 |
<li>حجم النموذج: 36.3 مليون باراميتر.</li>
|
| 74 |
</ul>
|
| 75 |
+
</div>
|
| 76 |
+
<div class="container col-xxl-8 px-4 py-5">
|
| 77 |
+
<div class="row flex-lg-row-reverse align-items-center g-5 py-5">
|
| 78 |
+
<div class="col-10 col-sm-8 col-lg-6">
|
| 79 |
+
<img src="bootstrap-themes.png" class="d-block mx-lg-auto img-fluid" alt="Bootstrap Themes" width="700" height="500" loading="lazy">
|
| 80 |
+
</div>
|
| 81 |
+
<div class="col-lg-6">
|
| 82 |
+
<h1 class="display-5 fw-bold lh-1 mb-3">Responsive left-aligned hero with image</h1>
|
| 83 |
+
<p class="lead">Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.</p>
|
| 84 |
+
<div class="d-grid gap-2 d-md-flex justify-content-md-start">
|
| 85 |
+
<button type="button" class="btn btn-primary btn-lg px-4 me-md-2">Primary</button>
|
| 86 |
+
<button type="button" class="btn btn-outline-secondary btn-lg px-4">Default</button>
|
| 87 |
+
</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
<div class="row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg">
|
| 92 |
+
<div class="col-lg-7 p-3 p-lg-5 pt-lg-3">
|
| 93 |
+
<h1 class="display-4 fw-bold lh-1">Border hero with cropped image and shadows</h1>
|
| 94 |
+
<p class="lead">Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.</p>
|
| 95 |
+
<div class="d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3">
|
| 96 |
+
<button type="button" class="btn btn-primary btn-lg px-4 me-md-2 fw-bold">Primary</button>
|
| 97 |
+
<button type="button" class="btn btn-outline-secondary btn-lg px-4">Default</button>
|
| 98 |
+
</div>
|
| 99 |
+
</div>
|
| 100 |
+
<div class="col-lg-4 offset-lg-1 p-0 overflow-hidden shadow-lg">
|
| 101 |
+
<img class="rounded-lg-3" src="bootstrap-docs.png" alt="" width="720">
|
| 102 |
+
</div>
|
| 103 |
+
</div>
|
| 104 |
+
<div class="bg-dark text-secondary px-4 py-5 text-center">
|
| 105 |
+
<div >
|
| 106 |
+
<h1 class="display-5 fw-bold text-white">Dark mode hero</h1>
|
| 107 |
+
<div class="col-lg-6 mx-auto">
|
| 108 |
+
<p class="fs-5 mb-4">Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.</p>
|
| 109 |
+
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
|
| 110 |
+
<button type="button" class="btn btn-outline-info btn-lg px-4 me-sm-3 fw-bold">Custom button</button>
|
| 111 |
+
<button type="button" class="btn btn-outline-light btn-lg px-4">Secondary</button>
|
| 112 |
+
</div>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
</div>
|
| 116 |
"""
|
| 117 |
|
| 118 |
# دالة صفحة "Chat AI"
|
| 119 |
def chat_ai_service():
|
| 120 |
return """
|
| 121 |
+
<div style='text-align: right; direction: rtl;'>
|
| 122 |
<h2>خدمة Chat AI</h2>
|
| 123 |
<p>خدمة تفاعلية تستخدم تقنيات الذكاء الاصطناعي المتقدمة لتوليد ردود طبيعية وسلسة على الرسائل.</p>
|
| 124 |
<p>تتميز هذه الخدمة بالقدرة على فهم اللهجة السعودية واستخدامها في الردود.</p>
|
|
|
|
| 128 |
<li>التعامل مع النص والصوت.</li>
|
| 129 |
<li>تعدد الاستخدامات: خدمة العملاء، الترفيه، التعليم، التسويق.</li>
|
| 130 |
</ul>
|
| 131 |
+
</div>
|
| 132 |
"""
|
| 133 |
|
| 134 |
# دالة صفحة "خدمات الرد بالصوت السعودي"
|
| 135 |
def saudi_voice_service():
|
| 136 |
return """
|
| 137 |
+
<div style='text-align: right; direction: rtl;'>
|
| 138 |
<h2>خدمة الرد بالصوت السعودي</h2>
|
| 139 |
<p>توليد أصوات واقعية باللهجة السعودية.</p>
|
| 140 |
<p>الخدمة مثالية لتطبيقات مثل المساعدات الصوتية أو الردود التفاعلية بالصوت.</p>
|
| 141 |
+
</div>
|
| 142 |
"""
|
| 143 |
|
| 144 |
# دالة صفحة "تحويل النص إلى اللهجة السعودية"
|
| 145 |
def text_to_najdi_service():
|
| 146 |
return """
|
| 147 |
+
<div style='text-align: right; direction: rtl;'>
|
| 148 |
<h2>تحويل النص من العربية إلى اللهجة السعودية</h2>
|
| 149 |
<p>هذه الخدمة تقوم بتحويل النصوص القياسية المكتوبة باللغة العربية إلى اللهجة السعودية، مما يجعلها مثالية لتطبيقات مثل المساعدات الصوتية أو الأنظمة التعليمية.</p>
|
| 150 |
+
</div>
|
| 151 |
"""
|
| 152 |
+
choices=[
|
| 153 |
+
"wasmdashai/vits-ar-sa-huba",
|
| 154 |
+
"wasmdashai/vits-ar-sa-ms",
|
| 155 |
+
"wasmdashai/vtk",
|
| 156 |
+
"wasmdashai/mak",
|
| 157 |
+
"wasmdashai/vits-ar-sa-huba-v1",
|
| 158 |
+
"wasmdashai/vits-ar-sa-huba-v2",
|
| 159 |
+
|
| 160 |
+
"wasmdashai/vits-ar-sa-A",
|
| 161 |
+
|
| 162 |
|
| 163 |
+
]
|
| 164 |
+
# إنشاء واجهة Gradio مع إضافة الـ Bootstrap و CSS مخصص لتبويبات RTL
|
| 165 |
with gr.Blocks() as demo:
|
| 166 |
+
# إضافة Bootstrap في الـ head
|
| 167 |
+
gr.HTML("""
|
| 168 |
+
<head>
|
| 169 |
+
<!-- Required meta tags -->
|
| 170 |
+
<meta charset="utf-8">
|
| 171 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 172 |
+
|
| 173 |
+
<!-- Bootstrap CSS -->
|
| 174 |
+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
|
| 175 |
+
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
|
| 176 |
+
|
| 177 |
+
<title>Wasm-Speeker</title>
|
| 178 |
+
</head>
|
| 179 |
+
""")
|
| 180 |
+
|
| 181 |
# العنوان الرئيسي
|
| 182 |
gr.Markdown("# Wasm-Speeker: إطار الذكاء الاصطناعي لتوليد الكلام")
|
| 183 |
+
|
| 184 |
# عرض الصورة الترحيبية
|
| 185 |
+
gr.Image("9588e6d4-9959-4cfc-9697-fc9b996fcd97.jpeg", label="Wasm-Speeker")
|
| 186 |
+
|
| 187 |
+
# إضافة CSS لجعل التبويبات RTL
|
| 188 |
+
gr.HTML("""
|
| 189 |
+
<style>
|
| 190 |
+
.gradio-tabs {
|
| 191 |
+
direction: rtl;
|
| 192 |
+
}
|
| 193 |
+
</style>
|
| 194 |
+
""")
|
| 195 |
|
| 196 |
# تبويبات الصفحات
|
| 197 |
with gr.Tabs():
|
| 198 |
# صفحة رئيسية
|
| 199 |
with gr.TabItem("الصفحة الرئيسية"):
|
| 200 |
+
gr.HTML(home_page())
|
| 201 |
|
| 202 |
# صفحة خدمة Chat AI
|
| 203 |
+
with gr.TabItem("Chat AI"):
|
| 204 |
+
gr.HTML(chat_ai_service())
|
| 205 |
+
text_input = gr.Textbox(label="الرسالة")
|
| 206 |
+
model_choices = gr.Dropdown(
|
| 207 |
+
choices=choices,
|
| 208 |
+
label="اختر النموذج",
|
| 209 |
+
value="wasmdashai/vits-ar-sa-huba-v2",
|
| 210 |
+
)
|
| 211 |
+
btn_submit=gr.Button("تحويل النص")
|
| 212 |
+
audio_output = gr.Audio(label="القصة")
|
| 213 |
+
|
| 214 |
+
btn_submit.click(modelspeech_ai, inputs=[text_input,model_choices], outputs=[audio_output])
|
| 215 |
+
|
| 216 |
+
|
| 217 |
|
| 218 |
# صفحة خدمة الرد بالصوت السعودي
|
| 219 |
+
with gr.TabItem("ChatBot"):
|
| 220 |
+
gr.HTML(saudi_voice_service())
|
| 221 |
|
| 222 |
# صفحة خدمة تحويل النص إلى اللهجة السعودية
|
| 223 |
+
with gr.TabItem("T2T"):
|
| 224 |
+
gr.HTML(text_to_najdi_service())
|
| 225 |
+
text_input = gr.Textbox(label="الرسالة")
|
| 226 |
+
|
| 227 |
+
btn_submit=gr.Button("تحويل النص")
|
| 228 |
+
text_output = gr.Textbox(label="القصة")
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
btn_submit.click(t2t, inputs=[text_input], outputs=[text_output])
|
| 233 |
|
| 234 |
# تشغيل الموقع
|
| 235 |
+
demo.launch( )
|