diff --git a/web-ui/js/app/voice.js b/web-ui/js/app/voice.js index b21e872..74ee68a 100644 --- a/web-ui/js/app/voice.js +++ b/web-ui/js/app/voice.js @@ -158,6 +158,7 @@ function _splitForSpeech(text) { var start = 0; for (var i = 0; i < text.length; i++) { if (text[i] === '.' && /\d/.test(text[i - 1] || '') && /\d/.test(text[i + 1] || '')) continue; // decimal point, not a boundary + if (text[i] === '.' && /[A-Za-z0-9]/.test(text[i - 1] || '') && /[A-Za-z]/.test(text[i + 1] || '')) continue; // domain dot (investing.com), not a boundary if (/[.!?\n]/.test(text[i])) { var j = i + 1; while (j < text.length && /[\s.!?]/.test(text[j])) j++; @@ -288,6 +289,8 @@ function _hourReplacer(m, numStr, suffix) { // bare "°C"/"°F" gets read as "그램"(grams) instead of degrees. function _cleanForSpeech(text) { if (typeof window !== 'undefined' && window.SpeechTables) text = window.SpeechTables.narrateTablesInText(text || ''); // 표 → 문장(speech-tables.js) + // 통화 낭독과 같은 규칙(날짜·시각·범위·도메인·쉼표 숫자·월 읽기 등)을 쓴다 — 두 벌로 갈라져 한쪽만 고쳐지던 문제(2026-10-20) + if (typeof window !== 'undefined' && typeof window.sanitizeForSpeech === 'function') return window.sanitizeForSpeech(text || ''); text = (typeof window !== 'undefined' && window.spellUnitsForSpeech) ? window.spellUnitsForSpeech(text || '') : (text || ''); // g/kg/GB/Hz… 단위 낭독(speech-units.js) return (text || '') .replace(/!\[.*?\]\(.*?\)/g, '') diff --git a/web-ui/js/voice/voice-call.js b/web-ui/js/voice/voice-call.js index 7063aa1..a4fde3f 100644 --- a/web-ui/js/voice/voice-call.js +++ b/web-ui/js/voice/voice-call.js @@ -449,7 +449,7 @@ // (일/이/삼...), specifically for clock hours and hour-durations — "9시" // is "아홉 시", never "구시" (reported 2026-07-10). Everything else (분, // 초, 도, %, dates, etc.) correctly stays Sino-Korean via _numToHangulWord. - const _NATIVE_HOUR = { 1: '한', 2: '두', 3: '세', 4: '네', 5: '다섯', 6: '여섯', 7: '일곱', 8: '여덟', 9: '아홉', 10: '열', 11: '열한', 12: '열두' }; + const _NATIVE_HOUR = { 1: '한', 2: '두', 3: '세', 4: '네', 5: '다섯', 6: '여섯', 7: '일곱', 8: '여덟', 9: '아홉', 10: '열', 11: '열한', 12: '열두', 13: '열세', 14: '열네', 15: '열다섯', 16: '열여섯', 17: '열일곱', 18: '열여덟', 19: '열아홉', 20: '스무', 21: '스물한', 22: '스물두', 23: '스물세', 24: '스물네' }; function _hourReplacer(m, numStr, suffix) { const n = parseInt(numStr, 10); return _NATIVE_HOUR[n] ? _NATIVE_HOUR[n] + suffix : m; @@ -469,11 +469,17 @@ } function sanitizeForSpeech(text) { + // 천 단위 쉼표(9,500 / 1,234,567)는 숫자 낭독 전에 제거한다. 안 그러면 "9"와 "500"이 따로 읽혀 + // "9,500원"이 "구, 오백원"이 되어 "천"이 통째로 사라진다(09-26 "단어가 한번씩 빠진다", 표의 가격 열). + // 단위 낭독보다 먼저여야 "$1,200"이 "1달러,200"으로 쪼개지지 않는다. + text = String(text || '').replace(/(?<=\d),(?=\d{3}(?!\d))/g, ''); text = window.spellUnitsForSpeech ? window.spellUnitsForSpeech(text) : text; // g/kg/GB/Hz… 단위 낭독(speech-units.js) return text - // 천 단위 쉼표(9,500 / 1,234,567)는 숫자 낭독 전에 제거한다. 안 그러면 "9"와 "500"이 따로 읽혀 - // "9,500원"이 "구, 오백원"이 되어 "천"이 통째로 사라진다(09-26 "단어가 한번씩 빠진다", 표의 가격 열). - .replace(/(?<=\d),(?=\d{3}(?!\d))/g, '') + // 날짜 2026-10-19 / 2026.10.19 / 2026/10/19 → "2026년 10월 19일"(안 그러면 마이너스·점으로 읽힌다). 월은 아래에서 시월·유월 처리. + .replace(/(? `${y}년 ${parseInt(mo, 10)}월 ${parseInt(d, 10)}일`) + // 시각 3:30 / 05:10 → "3시 30분"(정각이면 "3시"). 분이 한 자리인 3:1 같은 건 비율/점수로 "3 대 1". + .replace(/(? (+h <= 24 && +mi < 60) ? `${parseInt(h, 10)}시${+mi ? ' ' + parseInt(mi, 10) + '분' : ''}` : m) + .replace(/(?