mohmmed5787 commited on
Commit
8341eb6
·
verified ·
1 Parent(s): 45c7502

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -100
app.py CHANGED
@@ -1,102 +1,6 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
- """
4
- Hugging Face Spaces - Arabic Voice AI
5
- النسخة النهائية المحسّنة مع كشف الأخطاء الكامل
6
- """
7
 
8
- import json
9
- import sys
10
- import os
11
 
12
- NOTEBOOK_NAME = "Arabic_Voice_AI_COMPLETE_with_Narrator_Mimicry_FIXED.ipynb"
13
-
14
- def run_notebook(notebook_path):
15
- """تنفيذ Notebook مع error handling محسّن"""
16
-
17
- print("="*80)
18
- print(f"🚀 Loading notebook: {notebook_path}")
19
- print("="*80)
20
-
21
- # التأكد من وجود الملف
22
- if not os.path.exists(notebook_path):
23
- print(f"❌ File not found: {notebook_path}")
24
- sys.exit(1)
25
-
26
- # قراءة الـ Notebook
27
- with open(notebook_path, 'r', encoding='utf-8') as f:
28
- notebook = json.load(f)
29
-
30
- print(f"✅ Loaded {len(notebook['cells'])} cells")
31
- print("="*80)
32
- print()
33
-
34
- # ✅ الحل 1: إضافة __builtins__ للـ namespace
35
- global_namespace = {'__builtins__': __builtins__}
36
-
37
- # تنفيذ كل cell بالترتيب
38
- for i, cell in enumerate(notebook['cells']):
39
- if cell['cell_type'] == 'code':
40
- source = ''.join(cell['source'])
41
-
42
- # تجاهل الـ cells الفارغة
43
- if not source.strip():
44
- print(f"Cell {i:2}: ⏭️ Empty - skipped")
45
- continue
46
-
47
- # ✅ الحل 2: طباعة رقم Cell قبل التنفيذ
48
- first_line = source.strip().split('\n')[0][:60]
49
- print(f"Cell {i:2}: ⚙️ Executing... ({first_line})")
50
-
51
- try:
52
- # تنفيذ الكود
53
- exec(source, global_namespace)
54
-
55
- except Exception as e:
56
- # ✅ الحل 3: طباعة تفاصيل الخطأ الكاملة
57
- print()
58
- print("="*80)
59
- print(f"❌ FATAL ERROR IN CELL {i}")
60
- print("="*80)
61
- print(f"\nError Type: {type(e).__name__}")
62
- print(f"Error Message: {e}")
63
- print()
64
- print("Full Traceback:")
65
- print("-"*80)
66
-
67
- import traceback
68
- traceback.print_exc()
69
-
70
- print()
71
- print("="*80)
72
- print("🔍 Debugging Info:")
73
- print("="*80)
74
-
75
- # فحص الـ namespace للمساعدة في التشخيص
76
- important_classes = [
77
- 'Config',
78
- 'NarrativeAnalyzer',
79
- 'DynamicProsodyMapper',
80
- 'AdvancedAudioProcessor',
81
- 'NarrativeStyleApplicator',
82
- 'IntelligentVoiceEngine',
83
- 'VoiceInterface'
84
- ]
85
-
86
- print("\nClasses in namespace:")
87
- for cls in important_classes:
88
- status = "✅" if cls in global_namespace else "❌"
89
- print(f" {status} {cls}")
90
-
91
- print()
92
- print("="*80)
93
- sys.exit(1)
94
-
95
- print()
96
- print("="*80)
97
- print("✅ All cells executed successfully!")
98
- print("="*80)
99
-
100
- # تشغيل الـ Notebook
101
- if __name__ == "__main__":
102
- run_notebook(NOTEBOOK_NAME)
 
1
+ import gradio as gr
 
 
 
 
 
2
 
3
+ def test():
4
+ return "Space is working ✅"
 
5
 
6
+ gr.Interface(fn=test, inputs=[], outputs="text").launch()