joermd commited on
Commit
36480a4
·
verified ·
1 Parent(s): 280525f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +63 -139
index.html CHANGED
@@ -5,152 +5,40 @@
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>محادثة صوتية</title>
7
  <style>
8
- body {
9
- font-family: Arial, sans-serif;
10
- margin: 0;
11
- padding: 0;
12
- background: #f0f2f5;
13
- min-height: 100vh;
14
- display: flex;
15
- flex-direction: column;
16
- align-items: center;
17
- }
18
- .container {
19
- width: 100%;
20
- min-height: 100vh;
21
- display: flex;
22
- flex-direction: column;
23
- align-items: center;
24
- position: relative;
25
- }
26
- .record-button-container {
27
  width: 100%;
28
- height: 100vh;
29
  display: flex;
30
  justify-content: center;
31
  align-items: center;
32
- background: linear-gradient(135deg, #6e8efb, #4a6cf7);
33
- }
34
- .record-button {
35
- width: 80vmin;
36
- height: 80vmin;
37
- border-radius: 50%;
38
- background: rgba(255, 255, 255, 0.1);
39
- border: none;
40
- cursor: pointer;
41
- display: flex;
42
- align-items: center;
43
- justify-content: center;
44
- position: relative;
45
- transition: all 0.3s ease;
46
- box-shadow: 0 10px 30px rgba(0,0,0,0.2);
47
- backdrop-filter: blur(5px);
48
- }
49
- .record-button:hover {
50
- transform: scale(1.02);
51
- box-shadow: 0 15px 40px rgba(0,0,0,0.3);
52
  }
53
- .record-button.recording {
54
- background: rgba(255, 68, 68, 0.2);
55
- animation: pulse 2s infinite;
56
- }
57
- .record-button.recording .inner-circle {
58
- background: #ff4444;
59
- transform: scale(0.8);
60
  }
61
- .inner-circle {
62
- width: 40%;
63
- height: 40%;
 
64
  background: #ffffff;
65
- border-radius: 50%;
66
- transition: all 0.3s ease;
67
- box-shadow: 0 5px 15px rgba(0,0,0,0.2);
68
- }
69
- .status-text {
70
- position: absolute;
71
- bottom: 10%;
72
- text-align: center;
73
- color: white;
74
- font-size: 1.5rem;
75
- font-weight: bold;
76
- text-shadow: 0 2px 4px rgba(0,0,0,0.2);
77
- }
78
- .toggle-code-button {
79
- position: fixed;
80
- top: 20px;
81
- right: 20px;
82
- padding: 10px 20px;
83
- background: rgba(255, 255, 255, 0.2);
84
- border: none;
85
- border-radius: 25px;
86
- color: white;
87
- cursor: pointer;
88
- backdrop-filter: blur(5px);
89
- transition: all 0.3s ease;
90
- z-index: 1000;
91
- }
92
- .toggle-code-button:hover {
93
- background: rgba(255, 255, 255, 0.3);
94
  }
95
- .code-section {
96
- display: none;
97
- position: fixed;
98
- top: 0;
99
- left: 0;
100
- width: 100%;
101
- height: 100%;
102
- background: rgba(0, 0, 0, 0.95);
103
- z-index: 999;
104
- overflow-y: auto;
105
- padding: 20px;
106
- box-sizing: border-box;
107
- }
108
- .code-section.visible {
109
- display: block;
110
- }
111
- .message-container {
112
- background: rgba(255, 255, 255, 0.1);
113
- padding: 15px;
114
- border-radius: 15px;
115
- margin: 10px;
116
- backdrop-filter: blur(5px);
117
- color: white;
118
- width: 90%;
119
- max-width: 600px;
120
- }
121
- .message-label {
122
- font-weight: bold;
123
- margin-bottom: 8px;
124
- }
125
- .message-content {
126
- padding: 10px;
127
- background: rgba(255, 255, 255, 0.05);
128
- border-radius: 8px;
129
- min-height: 40px;
130
- }
131
- .voice-settings {
132
- position: fixed;
133
- bottom: 20px;
134
- width: 90%;
135
- max-width: 600px;
136
- padding: 15px;
137
- background: rgba(255, 255, 255, 0.1);
138
- border-radius: 15px;
139
- backdrop-filter: blur(5px);
140
- }
141
- select {
142
- width: 100%;
143
- padding: 12px;
144
- border-radius: 10px;
145
- border: 1px solid rgba(255, 255, 255, 0.2);
146
- background: rgba(255, 255, 255, 0.1);
147
- color: white;
148
- font-size: 16px;
149
- }
150
- @keyframes pulse {
151
- 0% { transform: scale(1); }
152
- 50% { transform: scale(1.05); }
153
- 100% { transform: scale(1); }
154
  }
155
  </style>
156
  </head>
@@ -165,6 +53,15 @@
165
  </div>
166
  <div class="status-text" id="statusText">انقر للبدء في التسجيل</div>
167
 
 
 
 
 
 
 
 
 
 
168
  <div class="code-section" id="codeSection">
169
  <div class="message-container">
170
  <div class="message-label">ما قلته:</div>
@@ -193,6 +90,7 @@
193
  const voiceSelect = document.getElementById('voiceSelect');
194
  const toggleCodeButton = document.getElementById('toggleCode');
195
  const codeSection = document.getElementById('codeSection');
 
196
 
197
  let isRecording = false;
198
 
@@ -210,14 +108,30 @@
210
  const voices = speechSynthesis.getVoices();
211
  voiceSelect.innerHTML = '<option value="">اختر صوت رجل عربي فصحى</option>';
212
 
 
213
  voices.forEach((voice, index) => {
214
- if (voice.lang.includes('ar') && voice.name.includes('Male')) {
215
  const option = document.createElement('option');
216
  option.value = index;
217
  option.textContent = voice.name;
 
 
 
218
  voiceSelect.appendChild(option);
219
  }
220
  });
 
 
 
 
 
 
 
 
 
 
 
 
221
  }
222
 
223
  speechSynthesis.onvoiceschanged = loadVoices;
@@ -247,6 +161,15 @@
247
  utterance.lang = 'ar-SA';
248
  utterance.rate = 1;
249
  utterance.pitch = 1;
 
 
 
 
 
 
 
 
 
250
  speechSynthesis.speak(utterance);
251
  } catch (error) {
252
  modelResponse.textContent = 'حدث خطأ في الاتصال بالنموذج';
@@ -275,6 +198,7 @@
275
  statusText.textContent = 'جارٍ التسجيل... انقر للإيقاف';
276
  spokenText.textContent = '';
277
  modelResponse.textContent = '';
 
278
  } else {
279
  recognition.stop();
280
  isRecording = false;
 
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>محادثة صوتية</title>
7
  <style>
8
+ /* ... Previous CSS styles ... */
9
+ .wave-container {
10
+ position: fixed;
11
+ bottom: 100px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  width: 100%;
13
+ height: 100px;
14
  display: flex;
15
  justify-content: center;
16
  align-items: center;
17
+ gap: 8px;
18
+ opacity: 0;
19
+ transition: opacity 0.3s ease;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
+
22
+ .wave-container.active {
23
+ opacity: 1;
 
 
 
 
24
  }
25
+
26
+ .wave {
27
+ width: 8px;
28
+ height: 40px;
29
  background: #ffffff;
30
+ border-radius: 4px;
31
+ animation: wave 1s ease-in-out infinite;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
+
34
+ .wave:nth-child(2) { animation-delay: 0.1s; }
35
+ .wave:nth-child(3) { animation-delay: 0.2s; }
36
+ .wave:nth-child(4) { animation-delay: 0.3s; }
37
+ .wave:nth-child(5) { animation-delay: 0.4s; }
38
+
39
+ @keyframes wave {
40
+ 0%, 100% { transform: scaleY(0.3); }
41
+ 50% { transform: scaleY(1); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
  </style>
44
  </head>
 
53
  </div>
54
  <div class="status-text" id="statusText">انقر للبدء في التسجيل</div>
55
 
56
+ <!-- إضافة حاوية الموجات الصوتية -->
57
+ <div class="wave-container" id="waveContainer">
58
+ <div class="wave"></div>
59
+ <div class="wave"></div>
60
+ <div class="wave"></div>
61
+ <div class="wave"></div>
62
+ <div class="wave"></div>
63
+ </div>
64
+
65
  <div class="code-section" id="codeSection">
66
  <div class="message-container">
67
  <div class="message-label">ما قلته:</div>
 
90
  const voiceSelect = document.getElementById('voiceSelect');
91
  const toggleCodeButton = document.getElementById('toggleCode');
92
  const codeSection = document.getElementById('codeSection');
93
+ const waveContainer = document.getElementById('waveContainer');
94
 
95
  let isRecording = false;
96
 
 
108
  const voices = speechSynthesis.getVoices();
109
  voiceSelect.innerHTML = '<option value="">اختر صوت رجل عربي فصحى</option>';
110
 
111
+ // تحسين اختيار الأصوات العربية للرجال
112
  voices.forEach((voice, index) => {
113
+ if (voice.lang.includes('ar') && (voice.name.includes('Male') || voice.name.includes('رجل'))) {
114
  const option = document.createElement('option');
115
  option.value = index;
116
  option.textContent = voice.name;
117
+ if (voice.default) {
118
+ option.selected = true;
119
+ }
120
  voiceSelect.appendChild(option);
121
  }
122
  });
123
+
124
+ // إذا لم يتم العثور على أصوات عربية، اختر أول صوت رجل متاح
125
+ if (voiceSelect.options.length === 1) {
126
+ voices.forEach((voice, index) => {
127
+ if (voice.name.includes('Male')) {
128
+ const option = document.createElement('option');
129
+ option.value = index;
130
+ option.textContent = voice.name;
131
+ voiceSelect.appendChild(option);
132
+ }
133
+ });
134
+ }
135
  }
136
 
137
  speechSynthesis.onvoiceschanged = loadVoices;
 
161
  utterance.lang = 'ar-SA';
162
  utterance.rate = 1;
163
  utterance.pitch = 1;
164
+
165
+ // إظهار الموجات الصوتية عند بدء الكلام
166
+ waveContainer.classList.add('active');
167
+
168
+ utterance.onend = () => {
169
+ // إخفاء الموجات الصوتية عند انتهاء الكلام
170
+ waveContainer.classList.remove('active');
171
+ };
172
+
173
  speechSynthesis.speak(utterance);
174
  } catch (error) {
175
  modelResponse.textContent = 'حدث خطأ في الاتصال بالنموذج';
 
198
  statusText.textContent = 'جارٍ التسجيل... انقر للإيقاف';
199
  spokenText.textContent = '';
200
  modelResponse.textContent = '';
201
+ waveContainer.classList.remove('active');
202
  } else {
203
  recognition.stop();
204
  isRecording = false;