TTS 送信前に英語駅名のマクロンを除去して誤読を防ぐ#6407
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📝 WalkthroughWalkthrough英語SSMLの可視テキストからマクロンを除去する処理を追加し、正規化結果をキャッシュキーとTTSリクエストに適用しました。タグや Changes英語SSMLマクロン正規化
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/utils/ttsSpeechFetcher.test.ts (1)
212-234: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low valueph属性の検証文字がマクロン除去の対象外。
コメントでは「ph 属性内の IPA (長音 ː) はそのまま」保持されることを検証する意図ですが、
ː(U+02D0 MODIFIER LETTER TRIANGULAR COLON)はstripMacronsが対象とする結合マクロン(U+0304)とは異なる文字です。そのため、このテストは「タグ内テキストがマクロン除去処理を通過しない」ことを直接的には証明できていません(ːはタグ外に出しても除去されないため)。タグ保護ロジックをより厳密に検証するなら、属性値に実際のマクロン付き文字(例:
ph="toːkjoō"のような形)を含めるとよいでしょう。🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/utils/ttsSpeechFetcher.test.ts` around lines 212 - 234, Update the test case around fetchSpeechAudio to include an actual U+0304 combining macron in the phoneme ph attribute, such as the suggested IPA value, while retaining a visible-text macron that should be removed. Adjust the expected ssmlEn assertion so it verifies the attribute macron is preserved and only the visible text is normalized.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/utils/ttsSpeechFetcher.test.ts`:
- Around line 212-234: Update the test case around fetchSpeechAudio to include
an actual U+0304 combining macron in the phoneme ph attribute, such as the
suggested IPA value, while retaining a visible-text macron that should be
removed. Adjust the expected ssmlEn assertion so it verifies the attribute
macron is preserved and only the visible text is normalized.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bb6e9e5b-f93d-47db-b050-1fa1c5f1e169
📒 Files selected for processing (2)
src/utils/ttsSpeechFetcher.test.tssrc/utils/ttsSpeechFetcher.ts
概要
TTS API へ送る英語アナウンス文からヘボン式長音符(マクロン)を除去し、マクロン付きの英語駅名(例:
Tōkyō/Kiryū/Ōhirashita)が誤読・無音化される問題を防ぎます。変更の種類
変更内容
ttsSpeechFetcherに送信直前のマクロン除去を追加。normalize('NFD')で結合マクロン(U+0304)へ分解 → 除去 →normalize('NFC')で再結合し、ō → oなどへ正規化する(既存のuseIsDifferentStationNameと同じ手法)。<...>)は属性ごと保護し、タグ外の可視テキストだけを対象にすることで、<phoneme ph="...">の IPA 発音記号を壊さず温存する。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ること関連Issue
スクリーンショット(任意)
Summary by CodeRabbit