fix(dictation): join retried phrases with the same spacing rule

This commit is contained in:
Kelvin Amoaba
2026-11-09 19:27:51 +00:00
parent 28ff84f683
commit 6640bee95c
2 changed files with 6 additions and 2 deletions
@@ -6,6 +6,7 @@ import type { DictationContext } from '../../../../shared/speech-types'
import type { DictationInsertionTarget } from './dictation-insertion-target'
import type { DictationTranscriptDelivery } from './dictation-transcript-delivery'
import { trimLandedOverlap } from './dictation-retry-overlap'
import { appendDictationText } from '../../../../shared/dictation-transcript-spacing'
import { showRetryOverlapUnmatchedToast } from './dictation-toasts'
// The cloud cap, ten minutes, is about 38 MB of 16 kHz float audio.
@@ -92,7 +93,10 @@ function* joinIntoBlocks(chunks: Float32Array[]): Generator<Float32Array> {
// The retry repeats words that landed before the failure; only what follows them is typed.
function insertAfterLanded(recording: DictationKeptRecording, retried: string[]): void {
const { text, matched } = trimLandedOverlap(recording.deliver.landedText(), retried.join(' '))
const { text, matched } = trimLandedOverlap(
recording.deliver.landedText(),
retried.reduce(appendDictationText, '')
)
if (text) {
recording.deliver(text, recording.target)
}
+1 -1
View File
@@ -4,7 +4,7 @@ export const DICTATION_TEXT_BLOCK_SELECTOR =
// Chinese and Japanese don't space words or after their full-width punctuation; Korean does, so Hangul spaces like Latin text.
const UNSPACED_SCRIPT_CHAR_RE =
/^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\u30fc\uff00-\uffef]$/u
/^[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\u3000-\u303f\u30fb\u30fc\uff00-\uff9f\uffe0-\uffef]$/u
const NO_SPACE_BEFORE_CHAR_RE = /^[,.;:!?%。,、!?;:))\]}”’»]$/u
const NO_SPACE_AFTER_CHAR_RE = /^[([{(《「『“‘«„]$/u
const STRAIGHT_QUOTE_RE = /["'`]/