diff --git a/dist/index.html b/dist/index.html
index 074bfc1..c1061ac 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -392,22 +392,33 @@ function stopRecording() {
if (mediaRecorder && mediaRecorder.state === 'recording') mediaRecorder.stop();
}
-// ---------- Воспроизведение ----------
+// ---------- Воспроизведение (с обрезкой тишины) ----------
+async function playTrimmed(blob) {
+ const t = await trimSilence(blob);
+ const ctx = getAudioCtx();
+ let buf;
+ if (t) {
+ const offline = new OfflineAudioContext(1, t.data.length, t.sr);
+ buf = offline.createBuffer(1, t.data.length, t.sr);
+ buf.getChannelData(0).set(t.data);
+ } else {
+ const ab = await blob.arrayBuffer();
+ buf = await ctx.decodeAudioData(ab);
+ }
+ const src = ctx.createBufferSource();
+ src.buffer = buf;
+ src.connect(ctx.destination);
+ src.start();
+ return new Promise(resolve => { src.onended = resolve; });
+}
+
async function playRec(id) {
try {
const db = await openRecDB();
const tx = db.transaction('recs', 'readonly');
const store = tx.objectStore('recs');
const rec = await new Promise(r => { const req = store.get(id); req.onsuccess = () => r(req.result); });
- if (rec?.blob) {
- const url = URL.createObjectURL(rec.blob);
- const audio = new Audio(url);
- await new Promise((resolve, reject) => {
- audio.onended = () => { URL.revokeObjectURL(url); resolve(); };
- audio.onerror = () => { URL.revokeObjectURL(url); reject(); };
- audio.play();
- });
- }
+ if (rec?.blob) await playTrimmed(rec.blob);
} catch(e) { /* тихо */ }
}
@@ -733,7 +744,7 @@ async function doCompare(blob, originalText, duration) {