perf/pipeline-improvements #2
@@ -60,13 +60,19 @@
|
|||||||
function finishEditing(segmentId: string) {
|
function finishEditing(segmentId: string) {
|
||||||
const trimmed = editText.trim();
|
const trimmed = editText.trim();
|
||||||
if (trimmed) {
|
if (trimmed) {
|
||||||
// Update the segment text and rebuild words from the edited text.
|
|
||||||
// The display renders segment.words, so we must update them too.
|
|
||||||
segments.update(segs => segs.map(s => {
|
segments.update(segs => segs.map(s => {
|
||||||
if (s.id !== segmentId) return s;
|
if (s.id !== segmentId) return s;
|
||||||
// Rebuild words from the edited text, preserving timing from the
|
const newWordTexts = trimmed.split(/\s+/);
|
||||||
// original segment boundaries (individual word timing is lost on edit)
|
let newWords;
|
||||||
const newWords = trimmed.split(/\s+/).map((word, widx) => ({
|
if (newWordTexts.length === s.words.length) {
|
||||||
|
// Same word count (e.g. spelling fix) — preserve each word's timing
|
||||||
|
newWords = s.words.map((w, widx) => ({
|
||||||
|
...w,
|
||||||
|
word: newWordTexts[widx],
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
// Word count changed — fall back to segment-level timing
|
||||||
|
newWords = newWordTexts.map((word, widx) => ({
|
||||||
id: `${s.id}-word-${widx}`,
|
id: `${s.id}-word-${widx}`,
|
||||||
segment_id: s.id,
|
segment_id: s.id,
|
||||||
word,
|
word,
|
||||||
@@ -75,6 +81,7 @@
|
|||||||
confidence: 1.0,
|
confidence: 1.0,
|
||||||
word_index: widx,
|
word_index: widx,
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
...s,
|
...s,
|
||||||
text: trimmed,
|
text: trimmed,
|
||||||
|
|||||||
Reference in New Issue
Block a user