Spaces:
Running
Running
muralipala1504 commited on
Commit ยท
a0409b4
1
Parent(s): a11e38d
feat: add multilingual TTS selector (UI ready, EN working)
Browse files- app.js +9 -0
- index.html +7 -0
app.js
CHANGED
|
@@ -58,6 +58,11 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
| 58 |
window.ttsEnabled = false;
|
| 59 |
window.lastSpokenText = "";
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
window.toggleTTS = function() {
|
| 62 |
window.ttsEnabled = !window.ttsEnabled;
|
| 63 |
const btn = document.getElementById("tts-btn");
|
|
@@ -95,6 +100,10 @@ window.speakText = function(text) {
|
|
| 95 |
function speakNext() {
|
| 96 |
if (i >= chunks.length || !window.ttsEnabled) return;
|
| 97 |
const utt = new SpeechSynthesisUtterance(chunks[i].trim());
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
utt.rate = 0.95;
|
| 99 |
utt.pitch = 1.0;
|
| 100 |
utt.volume = 1.0;
|
|
|
|
| 58 |
window.ttsEnabled = false;
|
| 59 |
window.lastSpokenText = "";
|
| 60 |
|
| 61 |
+
window.ttsLang = 'en-US';
|
| 62 |
+
window.setLang = function(lang) {
|
| 63 |
+
window.ttsLang = lang;
|
| 64 |
+
window.speechSynthesis.cancel();
|
| 65 |
+
};
|
| 66 |
window.toggleTTS = function() {
|
| 67 |
window.ttsEnabled = !window.ttsEnabled;
|
| 68 |
const btn = document.getElementById("tts-btn");
|
|
|
|
| 100 |
function speakNext() {
|
| 101 |
if (i >= chunks.length || !window.ttsEnabled) return;
|
| 102 |
const utt = new SpeechSynthesisUtterance(chunks[i].trim());
|
| 103 |
+
utt.lang = window.ttsLang;
|
| 104 |
+
const voices = window.speechSynthesis.getVoices();
|
| 105 |
+
const match = voices.find(v => v.lang === window.ttsLang);
|
| 106 |
+
if (match) utt.voice = match;
|
| 107 |
utt.rate = 0.95;
|
| 108 |
utt.pitch = 1.0;
|
| 109 |
utt.volume = 1.0;
|
index.html
CHANGED
|
@@ -375,6 +375,13 @@
|
|
| 375 |
<button class="theme-btn" id="theme-btn" onclick="toggleTheme()" title="Toggle light/dark theme">๐</button>
|
| 376 |
<button id="tts-btn" class="tts-btn" onclick="toggleTTS()" title="Voice OFF โ click to enable">๐ Voice</button>
|
| 377 |
<button class="tts-btn" onclick="replayLast()" title="Replay last response">๐ Replay</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
<button id="export-btn" class="header-btn" title="Export chat as Markdown">
|
| 379 |
๐ฅ Export
|
| 380 |
</button>
|
|
|
|
| 375 |
<button class="theme-btn" id="theme-btn" onclick="toggleTheme()" title="Toggle light/dark theme">๐</button>
|
| 376 |
<button id="tts-btn" class="tts-btn" onclick="toggleTTS()" title="Voice OFF โ click to enable">๐ Voice</button>
|
| 377 |
<button class="tts-btn" onclick="replayLast()" title="Replay last response">๐ Replay</button>
|
| 378 |
+
<select id="lang-select" class="header-btn" onchange="setLang(this.value)" title="TTS Language">
|
| 379 |
+
<option value="en-US">๐บ๐ธ EN</option>
|
| 380 |
+
<option value="hi-IN">๐ฎ๐ณ HI</option>
|
| 381 |
+
<option value="ta-IN">๐ฎ๐ณ TA</option>
|
| 382 |
+
<option value="te-IN">๐ฎ๐ณ TE</option>
|
| 383 |
+
<option value="ar-SA">๐ธ๐ฆ AR</option>
|
| 384 |
+
</select>
|
| 385 |
<button id="export-btn" class="header-btn" title="Export chat as Markdown">
|
| 386 |
๐ฅ Export
|
| 387 |
</button>
|