Skip to content

Commit 1c638e1

Browse files
JSKittyclaude
andcommitted
fix: restore transcription word highlighting during audio playback
Re-wire highlightCurrentSection() and clearHighlighting() which became dead code when the HTML5 audio element was replaced with the Rust cpal engine. The visualizer loop now highlights the active transcription section each frame, and pause/ended clear the highlight. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9a332b0 commit 1c638e1

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/js/voice.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,10 @@ function handleAudioAttachment(cAttachment, pMessage, msg) {
15291529

15301530
currentTimeEl.textContent = formatTime(posMs / 1000);
15311531

1532+
// Highlight active transcription section if visible
1533+
const tContainer = audioContainer.querySelector('.transcription-result:not(.hidden)');
1534+
if (tContainer) highlightCurrentSection(tContainer, posMs);
1535+
15321536
if (posMs >= durationMs) return; // Let ended event handle cleanup
15331537

15341538
animationId = requestAnimationFrame(updateVisualizerFromData);
@@ -1674,6 +1678,10 @@ function handleAudioAttachment(cAttachment, pMessage, msg) {
16741678
animationId = null;
16751679
}
16761680

1681+
// Clear transcription highlighting
1682+
const tContainer = audioContainer.querySelector('.transcription-result');
1683+
if (tContainer) clearHighlighting(tContainer);
1684+
16771685
// Smoothly wind down bars to paused state
16781686
if (durationMs > 0) {
16791687
const pausedPos = Math.min(playStartPos + (performance.now() - playStartTime), durationMs);
@@ -1811,6 +1819,10 @@ function handleAudioAttachment(cAttachment, pMessage, msg) {
18111819
customPlayer.classList.remove('playing');
18121820
currentTimeEl.textContent = '0:00';
18131821

1822+
// Clear transcription highlighting
1823+
const tContainer = audioContainer.querySelector('.transcription-result');
1824+
if (tContainer) clearHighlighting(tContainer);
1825+
18141826
if (animationId) {
18151827
cancelAnimationFrame(animationId);
18161828
animationId = null;

0 commit comments

Comments
 (0)