From 9f8c71077f47190c56f04cdae321c8099778d3b5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 6 Sep 2026 16:18:02 +0000 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E8=AA=9ETTS=E3=81=A7=E3=80=8CSeibu?= =?UTF-8?q?=E3=80=8D=E3=81=8C=E3=80=8C=E3=81=95=E3=81=84=E3=81=B6=E3=80=8D?= =?UTF-8?q?=E3=81=A8=E8=AA=AD=E3=81=BE=E3=82=8C=E3=82=8B=E8=AA=A4=E8=AA=AD?= =?UTF-8?q?=E3=82=92=E5=90=88=E6=88=90=E5=89=8D=E3=81=AE=E8=A1=A8=E8=A8=98?= =?UTF-8?q?=E7=BD=AE=E6=8F=9B=E3=81=A7=E4=BF=AE=E6=AD=A3=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01WS1LSBnYTMfm7CyrzqKxuW --- src/utils/normalize.test.ts | 14 ++++++++++++++ src/utils/normalize.ts | 6 ++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/utils/normalize.test.ts b/src/utils/normalize.test.ts index 63948d1..40e7ac7 100644 --- a/src/utils/normalize.test.ts +++ b/src/utils/normalize.test.ts @@ -43,11 +43,25 @@ describe('utils/normalize.ts', () => { expect(normalizeRomanText('Keiseibus')).toBe('Keiseibus'); }); + it('replaces Seibu with a spelling English TTS reads as せいぶ', () => { + expect( + normalizeRomanText('Change here for the Seibu Ikebukuro Line.') + ).toBe('Change here for the Say-boo Ikebukuro Line.'); + expect(normalizeRomanText('The next station is Seibu-Shinjuku.')).toBe( + 'The next station is Say-boo-shinjuku.' + ); + // 西武園 (Seibuen) は 1 語なので語単位の一致では対象外 + expect(normalizeRomanText('Seibuen')).toBe('Seibuen'); + }); + it('keeps Kay-say stable when normalized twice', () => { // 二重に適用しても結果が変わらないこと(キャッシュキーの安定性) expect(normalizeRomanText(normalizeRomanText('Keisei Main Line'))).toBe( 'Kay-say Main Line' ); + expect(normalizeRomanText(normalizeRomanText('Seibu Shinjuku Line'))).toBe( + 'Say-boo Shinjuku Line' + ); }); it.each(['Tokyo', 'tOkyo'])('text: %s', (text) => { diff --git a/src/utils/normalize.ts b/src/utils/normalize.ts index c777663..cfd4deb 100644 --- a/src/utils/normalize.ts +++ b/src/utils/normalize.ts @@ -35,12 +35,14 @@ const normalizeTextNode = (text: string): string => // 明治神宮前駅等の駅名にバッククォートが含まれる場合があるため除去 .replace(/`/g, '') .replace(/JR/gi, 'J-R') - // 「Keisei(京成)」は英語 TTS が "ei" を /aɪ/ と推定して「かいせい」と読むため、 - // 英単語 "Kay" + "say" で /keɪ.seɪ/(けいせい)を確定させる。読み替え先を + // 「Keisei(京成)」「Seibu(西武)」は英語 TTS が "ei" を /aɪ/ と推定して + // 「かいせい」「さいぶ」と読むため、英単語 "Kay" + "say" / "Say" + "boo" で + // /keɪ.seɪ/(けいせい)/ /seɪ.buː/(せいぶ)を確定させる。読み替え先を // 未知語の綴りにすると G2P の推定に戻ってエンジンごとに結果がぶれるので、 // 辞書語のハイフン連結にする。単語境界で一致させ、Keisei-Ueno のような // ハイフン連結の駅名も語単位で置換する .replace(/\bKeisei\b/gi, 'Kay-say') + .replace(/\bSeibu\b/gi, 'Say-boo') // 都営バスを想定 .replace(/\bSta\./gi, ' Station') .replace(/\bUniv\./gi, ' University')