mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
fix(dictation): join retried phrases with the same spacing rule
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 = /["'`]/
|
||||
|
||||
Reference in New Issue
Block a user