Update index.html
Browse files- index.html +114 -51
index.html
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
body {
|
9 |
font-family: Arial, sans-serif;
|
10 |
margin: 0;
|
11 |
-
padding:
|
12 |
background: #f0f2f5;
|
13 |
min-height: 100vh;
|
14 |
display: flex;
|
@@ -16,24 +16,26 @@
|
|
16 |
align-items: center;
|
17 |
}
|
18 |
.container {
|
19 |
-
max-width: 600px;
|
20 |
width: 100%;
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
25 |
}
|
26 |
.record-button-container {
|
|
|
|
|
27 |
display: flex;
|
28 |
justify-content: center;
|
29 |
align-items: center;
|
30 |
-
|
31 |
}
|
32 |
.record-button {
|
33 |
-
width:
|
34 |
-
height:
|
35 |
border-radius: 50%;
|
36 |
-
background:
|
37 |
border: none;
|
38 |
cursor: pointer;
|
39 |
display: flex;
|
@@ -41,66 +43,121 @@
|
|
41 |
justify-content: center;
|
42 |
position: relative;
|
43 |
transition: all 0.3s ease;
|
|
|
|
|
44 |
}
|
45 |
.record-button:hover {
|
46 |
-
|
|
|
47 |
}
|
48 |
.record-button.recording {
|
49 |
-
background:
|
|
|
50 |
}
|
51 |
.record-button.recording .inner-circle {
|
52 |
-
background:
|
53 |
-
|
54 |
-
height: 50px;
|
55 |
-
border-radius: 5px;
|
56 |
}
|
57 |
.inner-circle {
|
58 |
-
width:
|
59 |
-
height:
|
60 |
-
background: #
|
61 |
border-radius: 50%;
|
62 |
transition: all 0.3s ease;
|
|
|
63 |
}
|
64 |
.status-text {
|
|
|
|
|
65 |
text-align: center;
|
66 |
-
|
67 |
-
|
68 |
-
font-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
}
|
70 |
.message-container {
|
71 |
-
background:
|
72 |
padding: 15px;
|
73 |
-
border-radius:
|
74 |
-
margin: 10px
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
.message-label {
|
77 |
font-weight: bold;
|
78 |
-
color: #666;
|
79 |
margin-bottom: 8px;
|
80 |
}
|
81 |
.message-content {
|
82 |
padding: 10px;
|
83 |
-
background:
|
84 |
border-radius: 8px;
|
85 |
min-height: 40px;
|
86 |
}
|
87 |
.voice-settings {
|
88 |
-
|
|
|
|
|
|
|
89 |
padding: 15px;
|
90 |
-
background:
|
91 |
-
border-radius:
|
|
|
92 |
}
|
93 |
select {
|
94 |
width: 100%;
|
95 |
-
padding:
|
96 |
-
|
97 |
-
border
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
</style>
|
101 |
</head>
|
102 |
<body>
|
103 |
<div class="container">
|
|
|
|
|
104 |
<div class="record-button-container">
|
105 |
<button class="record-button" id="recordButton">
|
106 |
<div class="inner-circle"></div>
|
@@ -108,20 +165,22 @@
|
|
108 |
</div>
|
109 |
<div class="status-text" id="statusText">انقر للبدء في التسجيل</div>
|
110 |
|
111 |
-
<div class="
|
112 |
-
<
|
113 |
-
<
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
125 |
</div>
|
126 |
</div>
|
127 |
|
@@ -132,16 +191,21 @@
|
|
132 |
const spokenText = document.getElementById('spokenText');
|
133 |
const modelResponse = document.getElementById('modelResponse');
|
134 |
const voiceSelect = document.getElementById('voiceSelect');
|
|
|
|
|
135 |
|
136 |
let isRecording = false;
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
-
// إعداد التعرف على الكلام
|
139 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
140 |
recognition.lang = 'ar-SA';
|
141 |
recognition.continuous = false;
|
142 |
recognition.interimResults = false;
|
143 |
|
144 |
-
// تحميل الأصوات العربية
|
145 |
function loadVoices() {
|
146 |
const voices = speechSynthesis.getVoices();
|
147 |
voiceSelect.innerHTML = '<option value="">اختر صوت رجل عربي فصحى</option>';
|
@@ -176,7 +240,6 @@
|
|
176 |
const botReply = data.response;
|
177 |
modelResponse.textContent = botReply;
|
178 |
|
179 |
-
// تحويل الرد إلى صوت
|
180 |
const utterance = new SpeechSynthesisUtterance(botReply);
|
181 |
const voices = speechSynthesis.getVoices();
|
182 |
const selectedVoice = voices[voiceSelect.value || 0];
|
|
|
8 |
body {
|
9 |
font-family: Arial, sans-serif;
|
10 |
margin: 0;
|
11 |
+
padding: 0;
|
12 |
background: #f0f2f5;
|
13 |
min-height: 100vh;
|
14 |
display: flex;
|
|
|
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;
|
|
|
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>
|
157 |
<body>
|
158 |
<div class="container">
|
159 |
+
<button class="toggle-code-button" id="toggleCode">عرض النص</button>
|
160 |
+
|
161 |
<div class="record-button-container">
|
162 |
<button class="record-button" id="recordButton">
|
163 |
<div class="inner-circle"></div>
|
|
|
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>
|
171 |
+
<div class="message-content" id="spokenText"></div>
|
172 |
+
</div>
|
173 |
+
|
174 |
+
<div class="message-container">
|
175 |
+
<div class="message-label">رد النموذج:</div>
|
176 |
+
<div class="message-content" id="modelResponse"></div>
|
177 |
+
</div>
|
178 |
+
|
179 |
+
<div class="voice-settings">
|
180 |
+
<select id="voiceSelect">
|
181 |
+
<option value="">اختر صوت رجل عربي فصحى</option>
|
182 |
+
</select>
|
183 |
+
</div>
|
184 |
</div>
|
185 |
</div>
|
186 |
|
|
|
191 |
const spokenText = document.getElementById('spokenText');
|
192 |
const modelResponse = document.getElementById('modelResponse');
|
193 |
const voiceSelect = document.getElementById('voiceSelect');
|
194 |
+
const toggleCodeButton = document.getElementById('toggleCode');
|
195 |
+
const codeSection = document.getElementById('codeSection');
|
196 |
|
197 |
let isRecording = false;
|
198 |
+
|
199 |
+
toggleCodeButton.onclick = () => {
|
200 |
+
codeSection.classList.toggle('visible');
|
201 |
+
toggleCodeButton.textContent = codeSection.classList.contains('visible') ? 'إخفاء النص' : 'عرض النص';
|
202 |
+
};
|
203 |
|
|
|
204 |
const recognition = new (window.SpeechRecognition || window.webkitSpeechRecognition)();
|
205 |
recognition.lang = 'ar-SA';
|
206 |
recognition.continuous = false;
|
207 |
recognition.interimResults = false;
|
208 |
|
|
|
209 |
function loadVoices() {
|
210 |
const voices = speechSynthesis.getVoices();
|
211 |
voiceSelect.innerHTML = '<option value="">اختر صوت رجل عربي فصحى</option>';
|
|
|
240 |
const botReply = data.response;
|
241 |
modelResponse.textContent = botReply;
|
242 |
|
|
|
243 |
const utterance = new SpeechSynthesisUtterance(botReply);
|
244 |
const voices = speechSynthesis.getVoices();
|
245 |
const selectedVoice = voices[voiceSelect.value || 0];
|