Spaces:
Paused
Paused
UI/Fix: Gradient TTS player, better 5s skip chunks, immediate speed update (BUILD 1.5.3)
Browse files- index.html +1 -1
- src/services/tts-service.js +31 -13
- src/styles/global.css +4 -2
index.html
CHANGED
|
@@ -51,7 +51,7 @@
|
|
| 51 |
</head>
|
| 52 |
<body class="dark-theme in-chat-view">
|
| 53 |
|
| 54 |
-
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.5.
|
| 55 |
|
| 56 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 57 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
|
|
|
| 51 |
</head>
|
| 52 |
<body class="dark-theme in-chat-view">
|
| 53 |
|
| 54 |
+
<div id="live-version-badge" style="position: fixed; top: 50px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text-secondary); opacity: 0.6; z-index: 99999; pointer-events: none; font-weight: 500; font-family: monospace; letter-spacing: 1px; background: rgba(0,0,0,0.2); padding: 2px 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.05);">BUILD 1.5.3</div>
|
| 55 |
|
| 56 |
<!-- SVG Filters for Liquid Glass Refraction -->
|
| 57 |
<svg width="0" height="0" style="position: absolute; pointer-events: none;">
|
src/services/tts-service.js
CHANGED
|
@@ -53,20 +53,34 @@ class TTSService {
|
|
| 53 |
}
|
| 54 |
|
| 55 |
splitIntoChunks(text) {
|
| 56 |
-
// Split by punctuation (., ?, !, \n) to
|
| 57 |
-
|
| 58 |
-
const regex = /.*?[.!?\n]+(?=\s|$)|.+/g;
|
| 59 |
let chunks = [];
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
}
|
| 65 |
}
|
| 66 |
-
// Fallback if no punctuation is found or string is short
|
| 67 |
-
if (chunks.length === 0 && text.length > 0) {
|
| 68 |
-
chunks = [text];
|
| 69 |
-
}
|
| 70 |
return chunks;
|
| 71 |
}
|
| 72 |
|
|
@@ -152,8 +166,12 @@ class TTSService {
|
|
| 152 |
|
| 153 |
setRate(newRate) {
|
| 154 |
this.rate = newRate;
|
| 155 |
-
//
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
this.notifyState();
|
| 158 |
}
|
| 159 |
|
|
|
|
| 53 |
}
|
| 54 |
|
| 55 |
splitIntoChunks(text) {
|
| 56 |
+
// Split by punctuation (., ?, !, \n) first to preserve sentence intonation.
|
| 57 |
+
const sentences = text.match(/.*?[.!?\n]+(?=\s|$)|.+/g) || [];
|
|
|
|
| 58 |
let chunks = [];
|
| 59 |
+
|
| 60 |
+
for (let sentence of sentences) {
|
| 61 |
+
sentence = sentence.trim();
|
| 62 |
+
if (!sentence) continue;
|
| 63 |
+
|
| 64 |
+
// If a sentence is very long, break it into smaller ~60 character chunks
|
| 65 |
+
// so that skipping (which skips a chunk) feels like skipping ~5 seconds.
|
| 66 |
+
if (sentence.length > 80) {
|
| 67 |
+
const words = sentence.split(/\s+/);
|
| 68 |
+
let currentChunk = '';
|
| 69 |
+
for (const word of words) {
|
| 70 |
+
if ((currentChunk + ' ' + word).length > 65 && currentChunk.length > 0) {
|
| 71 |
+
chunks.push(currentChunk.trim());
|
| 72 |
+
currentChunk = word;
|
| 73 |
+
} else {
|
| 74 |
+
currentChunk += (currentChunk.length === 0 ? '' : ' ') + word;
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
if (currentChunk.trim().length > 0) {
|
| 78 |
+
chunks.push(currentChunk.trim());
|
| 79 |
+
}
|
| 80 |
+
} else {
|
| 81 |
+
chunks.push(sentence);
|
| 82 |
}
|
| 83 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
return chunks;
|
| 85 |
}
|
| 86 |
|
|
|
|
| 166 |
|
| 167 |
setRate(newRate) {
|
| 168 |
this.rate = newRate;
|
| 169 |
+
// Apply immediately by restarting the current chunk at the new speed.
|
| 170 |
+
if (this.isPlaying && this.utterance) {
|
| 171 |
+
this.utterance.onend = null; // Prevent skipping to next chunk
|
| 172 |
+
this.synth.cancel();
|
| 173 |
+
this.playChunk();
|
| 174 |
+
}
|
| 175 |
this.notifyState();
|
| 176 |
}
|
| 177 |
|
src/styles/global.css
CHANGED
|
@@ -3263,9 +3263,11 @@ body.in-chat-view .tts-player-container {
|
|
| 3263 |
}
|
| 3264 |
|
| 3265 |
.tts-player-inner {
|
| 3266 |
-
background: rgba(
|
|
|
|
|
|
|
| 3267 |
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 3268 |
-
border-radius:
|
| 3269 |
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255,255,255,0.1);
|
| 3270 |
overflow: hidden;
|
| 3271 |
display: flex;
|
|
|
|
| 3263 |
}
|
| 3264 |
|
| 3265 |
.tts-player-inner {
|
| 3266 |
+
background: linear-gradient(135deg, rgba(182, 120, 242, 0.15), rgba(255, 204, 0, 0.15)), rgba(20, 20, 25, 0.7);
|
| 3267 |
+
backdrop-filter: blur(20px);
|
| 3268 |
+
-webkit-backdrop-filter: blur(20px);
|
| 3269 |
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 3270 |
+
border-radius: 24px;
|
| 3271 |
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255,255,255,0.1);
|
| 3272 |
overflow: hidden;
|
| 3273 |
display: flex;
|