Spaces:
Sleeping
Sleeping
Update static/index.html
Browse files- static/index.html +61 -14
static/index.html
CHANGED
@@ -88,11 +88,58 @@
|
|
88 |
<body>
|
89 |
<div id="chat-container">
|
90 |
<select id="language-selector" class="form-control">
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
</select>
|
97 |
<div id="chat-history"></div>
|
98 |
<div class="input-group">
|
@@ -148,11 +195,11 @@
|
|
148 |
addMessage("Bot", botMessage, "bot-message");
|
149 |
chatHistoryArray.push({ sender: "Bot", message: botMessage });
|
150 |
if (data.audioUrl) {
|
151 |
-
|
152 |
const fullAudioUrl = `${baseUrl}/${data.audioUrl}`; // Append the audio URL to the base
|
153 |
-
playAudio(fullAudioUrl);
|
154 |
-
|
155 |
}
|
|
|
156 |
} catch (error) {
|
157 |
botTyping.remove();
|
158 |
console.error("Error:", error);
|
@@ -165,7 +212,6 @@
|
|
165 |
// Play audio from server response
|
166 |
function playAudio(url) {
|
167 |
if (!url) {
|
168 |
-
|
169 |
console.error("Audio URL is missing.");
|
170 |
addMessage("Bot", "Error: Unable to play audio.", "bot-message");
|
171 |
return;
|
@@ -178,14 +224,15 @@ function playAudio(url) {
|
|
178 |
addMessage("Bot", "Error: Unable to load audio.", "bot-message");
|
179 |
};
|
180 |
|
181 |
-
audio.
|
182 |
console.log("Playing audio:", url);
|
|
|
|
|
|
|
|
|
183 |
};
|
184 |
|
185 |
-
audio.
|
186 |
-
console.error("Error during audio playback:", error);
|
187 |
-
addMessage("Bot", "Error: Unable to play audio.", "bot-message");
|
188 |
-
});
|
189 |
}
|
190 |
|
191 |
|
|
|
88 |
<body>
|
89 |
<div id="chat-container">
|
90 |
<select id="language-selector" class="form-control">
|
91 |
+
|
92 |
+
<option value="en-US" selected>English</option>
|
93 |
+
<option value="hi-IN">हिंदी (Hindi)</option>
|
94 |
+
<option value="es-ES">Español (Spanish)</option>
|
95 |
+
<option value="fr-FR">Français (French)</option>
|
96 |
+
<option value="te-IN">తెలుగు (Telugu)</option>
|
97 |
+
<option value="ta-IN">தமிழ் (Tamil)</option>
|
98 |
+
<option value="kn-IN">ಕನ್ನಡ (Kannada)</option>
|
99 |
+
<option value="ml-IN">മലയാളം (Malayalam)</option>
|
100 |
+
<option value="mr-IN">मराठी (Marathi)</option>
|
101 |
+
<option value="gu-IN">ગુજરાતી (Gujarati)</option>
|
102 |
+
<option value="bn-IN">বাংলা (Bengali)</option>
|
103 |
+
<option value="pa-IN">ਪੰਜਾਬੀ (Punjabi)</option>
|
104 |
+
<option value="ur-IN">اردو (Urdu)</option>
|
105 |
+
<option value="zh-CN">简体中文 (Chinese Simplified)</option>
|
106 |
+
<option value="zh-TW">繁體中文 (Chinese Traditional)</option>
|
107 |
+
<option value="ja-JP">日本語 (Japanese)</option>
|
108 |
+
<option value="ko-KR">한국어 (Korean)</option>
|
109 |
+
<option value="de-DE">Deutsch (German)</option>
|
110 |
+
<option value="it-IT">Italiano (Italian)</option>
|
111 |
+
<option value="pt-PT">Português (Portuguese)</option>
|
112 |
+
<option value="pt-BR">Português (Brasil) (Portuguese Brazil)</option>
|
113 |
+
<option value="ru-RU">Русский (Russian)</option>
|
114 |
+
<option value="ar-SA">العربية (Arabic)</option>
|
115 |
+
<option value="id-ID">Bahasa Indonesia (Indonesian)</option>
|
116 |
+
<option value="vi-VN">Tiếng Việt (Vietnamese)</option>
|
117 |
+
<option value="th-TH">ไทย (Thai)</option>
|
118 |
+
<option value="tr-TR">Türkçe (Turkish)</option>
|
119 |
+
<option value="pl-PL">Polski (Polish)</option>
|
120 |
+
<option value="nl-NL">Nederlands (Dutch)</option>
|
121 |
+
<option value="sv-SE">Svenska (Swedish)</option>
|
122 |
+
<option value="da-DK">Dansk (Danish)</option>
|
123 |
+
<option value="fi-FI">Suomi (Finnish)</option>
|
124 |
+
<option value="no-NO">Norsk (Norwegian)</option>
|
125 |
+
<option value="cs-CZ">Čeština (Czech)</option>
|
126 |
+
<option value="hu-HU">Magyar (Hungarian)</option>
|
127 |
+
<option value="el-GR">Ελληνικά (Greek)</option>
|
128 |
+
<option value="ro-RO">Română (Romanian)</option>
|
129 |
+
<option value="sk-SK">Slovenčina (Slovak)</option>
|
130 |
+
<option value="uk-UA">Українська (Ukrainian)</option>
|
131 |
+
<option value="hr-HR">Hrvatski (Croatian)</option>
|
132 |
+
<option value="sr-RS">Српски (Serbian)</option>
|
133 |
+
<option value="bg-BG">Български (Bulgarian)</option>
|
134 |
+
<option value="lt-LT">Lietuvių (Lithuanian)</option>
|
135 |
+
<option value="lv-LV">Latviešu (Latvian)</option>
|
136 |
+
<option value="et-EE">Eesti (Estonian)</option>
|
137 |
+
<option value="sl-SI">Slovenščina (Slovenian)</option>
|
138 |
+
<option value="mt-MT">Malti (Maltese)</option>
|
139 |
+
<option value="sq-AL">Shqip (Albanian)</option>
|
140 |
+
<option value="mk-MK">Македонски (Macedonian)</option>
|
141 |
+
<option value="bs-BA">Bosanski (Bosnian)</option>
|
142 |
+
<option value="is-IS">Íslenska (Icelandic)</option>
|
143 |
</select>
|
144 |
<div id="chat-history"></div>
|
145 |
<div class="input-group">
|
|
|
195 |
addMessage("Bot", botMessage, "bot-message");
|
196 |
chatHistoryArray.push({ sender: "Bot", message: botMessage });
|
197 |
if (data.audioUrl) {
|
198 |
+
const baseUrl = window.location.origin; // Get the base URL (e.g., http://localhost:8000)
|
199 |
const fullAudioUrl = `${baseUrl}/${data.audioUrl}`; // Append the audio URL to the base
|
200 |
+
playAudio(fullAudioUrl); // Pass the constructed URL to playAudio
|
|
|
201 |
}
|
202 |
+
|
203 |
} catch (error) {
|
204 |
botTyping.remove();
|
205 |
console.error("Error:", error);
|
|
|
212 |
// Play audio from server response
|
213 |
function playAudio(url) {
|
214 |
if (!url) {
|
|
|
215 |
console.error("Audio URL is missing.");
|
216 |
addMessage("Bot", "Error: Unable to play audio.", "bot-message");
|
217 |
return;
|
|
|
224 |
addMessage("Bot", "Error: Unable to load audio.", "bot-message");
|
225 |
};
|
226 |
|
227 |
+
audio.oncanplaythrough = () => {
|
228 |
console.log("Playing audio:", url);
|
229 |
+
audio.play().catch((error) => {
|
230 |
+
console.error("Error during audio playback:", error);
|
231 |
+
addMessage("Bot", "Error: Unable to play audio.", "bot-message");
|
232 |
+
});
|
233 |
};
|
234 |
|
235 |
+
audio.load();
|
|
|
|
|
|
|
236 |
}
|
237 |
|
238 |
|