Skip to content

TTS文言を各テーマの公式車内放送の言い回しに刷新し、他社線直通境界駅の御礼・直通先案内放送を追加 - #6162

Merged
TinyKitten merged 2 commits into
devfrom
claude/tts-official-theme-wording-0sw39z
Jun 10, 2026
Merged

TinyKitten merged 2 commits into
devfrom
claude/tts-official-theme-wording-0sw39z

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

概要

TTSの読み上げ文言を、各テーマが模している鉄道事業者の実車自動放送の公式文言に合わせて書き換えました。文言は以下の一次資料・実車放送書き起こしで一字一句確認したものをベースにしています(会社名・路線名・駅番号はすべて既存の動的変数のままで、定型句のみ公式の言い回しに変更)。

  • TOEI: 東京都交通局 公式PDF「新宿線10-300形車両 自動放送内容リスト」
  • TOKYO_METRO: 銀座線 車内自動放送(現行)書き起こし
  • YAMANOTE / SAIKYO: JR東日本 通勤型(E233/E235系)自動放送の文章化資料
  • JR_WEST: みやこ路快速(223系近郊型)・大阪環状線(323系)書き起こし
  • TY: 東急東横線・東急多摩川線(現行)書き起こし
  • JR_KYUSHU: 信頼できる文字資料が見つからなかったため現行文言を維持

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • src/hooks/tts/templates.ts: 全テーマのNEXT/ARRIVINGテンプレートを公式文言に書き換え(YAMANOTE/SAIKYOはJR東日本 通勤型共通テンプレートに統合)
  • 東京メトロ: 始発挨拶を会社名ベースに変更、公式に存在しない到着前の乗換案内を削除、終点到着前に「お忘れ物なさいませんよう…」+御礼を追加
  • 東急: 駅名2回読み、「◯◯線ご利用のお客様はお乗り換えです」(「を」なし)、始発挨拶に「本日も」、終点到着前の御礼を公式構成に変更
  • 山手/埼京: 公式に存在しない始発挨拶「今日も〜ありがとうございます」を削除して列車案内のみに変更、通過駅の「◯◯へおいでのお客様と」連結と「◯◯の次は、◯◯に止まります。」(到着前)を追加、終点英語御礼を公式文言に修正
  • JR西日本: 発車後の乗換案内を削除(公式は到着前のみ)、終点到着前を「ご乗車ありがとうございました。まもなく終点・◯◯、◯◯です。…」の公式構成に変更、英語停車駅リストを「A, B, and C before arriving at X」形式に変更(formatJrWestStopsListEn)
  • 都営: 公式PDF準拠で駅名2回読み+「◯◯は、お乗り換えです。」、列車案内を始発時のみに変更、終点手前の「この電車は、◯◯止まりです。お忘れ物のないよう、ご注意ください。」、通過案内を「においでの方」「にとまります」に修正
  • 新機能: 他社線直通の境界駅で自社線利用への御礼+直通先の列車案内(「この電車は、◯◯線直通、…行きです。」)を放送する isNextStopThroughBoundary / nextLineJa / nextLineEn を useTTSText.ts に追加(東京メトロ・東急・都営テーマで使用。JR系は出典未確認のため対象外)
  • テスト: 全テーマの期待値を新文言に更新し、直通境界放送と formatJrWestStopsListEn のテストを追加

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

関連Issue

スクリーンショット(任意)


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • 直通境界駅の案内で直通先路線名を読み上げするようになりました(より正確な案内)
    • JR西日本向けの駅名列挙が「A, B, and C」形式に改善され、終着駅の表現がより自然になりました
  • Bug Fixes

    • 各テーマ(JR東日本・東京メトロ等)の放送文言を見直し、終点前後や通過境界での表現を統一しました
  • Tests

    • 多数の期待値テストを追加・更新し、放送文言の回帰検証を強化しました

@github-actions github-actions Bot added the react label Jun 10, 2026
@TinyKitten TinyKitten self-assigned this Jun 10, 2026
@coderabbitai

coderabbitai Bot commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7161268c-583f-458d-9263-fc6a2def3da9

📥 Commits

Reviewing files that changed from the base of the PR and between 3356c6c and 2d4239e.

📒 Files selected for processing (2)
  • src/hooks/tts/formatters.test.ts
  • src/hooks/tts/formatters.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/hooks/tts/formatters.ts

📝 Walkthrough

Walkthrough

複数電車テーマの車内自動放送テンプレートを公式放送に統一。JR-West停留所リスト表現の変更、TTS文脈構築ロジック(直通境界駅判定、線路/列車種別情報の事前計算)の拡張、5テーマのテンプレート文言(終点/乗換案内/英語語彙)の再構成、および対応する回帰テストの整備。

Changes

TTS放送テンプレートシステムの公式文言対応化

Layer / File(s) Summary
JR-West停留所リスト表現の改善
src/hooks/tts/formatters.ts, src/hooks/tts/formatters.test.ts
JR-West向け英語停留所リストの出力形式を , 区切りから A, B, and C 形式に変更。末尾が終着駅かつ複数駅の場合は終着駅を「before arriving at」句に移すロジックを追加し、テストで各パターン(and結合、before arriving at変換、2停留所、最大5駅スライス)を検証。
TTS文脈構築ロジックの拡張
src/hooks/useTTSText.ts
直通境界駅判定(stationAfterNextStop、throughLine、isNextStopThroughBoundary)を導入し、路線名・列車種別名の事前計算(currentLineJa/currentLineEn、currentTrainTypeJa/currentTrainTypeEn)で複数箇所での参照を統一。announceVehicleSummary と vehicleEnPlural を削除し、nextLineJa/nextLineEn をコンテキストに追加。
複数テーマのテンプレート文言再構成
src/hooks/tts/templates.ts
TOKYO_METRO、TY、JR_EAST、JR_WEST、TOEI およびそれぞれの英語版テンプレートの NEXT/ARRIVING 文言を公式放送仕様に対応させ、終点/到着前/通過境界での御礼文、乗換案内の条件出し分け、次駅以後の案内の出力構造を更新。終点関連の英語語彙(last stop→final stop 等)も統一。YAMANOTE と SAIKYO を専用テンプレートから JR_EAST/JR_EAST_EN へ統合。
useTTSText回帰テスト更新
src/hooks/useTTSText.test.tsx
TOKYO_METRO、TY、YAMANOTE、JR_WEST、SAIKYO、TOEI、LED の NEXT/ARRIVING 期待値を公式仕様に更新。乗換案内の有無、句読点の変更(「次は、」→「次は」)、終点告知パターン(Thanks文言と終点の冒頭配置確認)を追加。新規「through service boundary announcement」テストスイートで直通境界駅での案内(京王線切り替え含む)を検証。
バスモードTTS回帰テスト更新
src/hooks/useTTSText.bus.test.tsx
バスモード用テストの期待値を更新。TOKYO_METRO の英語フレーズを「This bus is bound for」に統一し、YAMANOTE/SAIKYO/JO/JL の日本語文言を「今日も」から「このバスは」+「ゆきです」に変更。公式JR東日本放送仕様に関するコメントを追加。

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • TrainLCD/MobileApp#5997: TTSパイプラインの共有コンテキストフラグ(announceVehicleSummary 等)に関する変更が重複しているため、整合性確認が必要。
  • TrainLCD/MobileApp#6135: useTTSText 周辺で次駅表示ロジックが変更されており、同フックのコンテキスト/表示連携を確認する必要あり.

Suggested labels

react

Poem

🐰 駅名を並べて歌うよ、
カンマと And でそっと結んで、
終着は「before arriving at」で囁き、
テストで確かめてまた安心、
走れ、放送、乗客の耳へ。

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRのタイトルは、TTS文言の公式車内放送への刷新と他社線直通境界駅の案内放送追加という主要な変更内容を的確に要約しており、変更セット全体を適切に代表しています。
Description check ✅ Passed PR説明は、テンプレートの全必須セクション(概要・変更種類・変更内容・テスト・関連Issue)を完備しており、変更の背景、実装内容、テスト実施状況が明確に記述されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/tts-official-theme-wording-0sw39z

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/hooks/tts/formatters.test.ts (1)

1-11: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

afterEach で jest.clearAllMocks() を追加してください。

このファイルは *.test.ts ですが、モック状態のクリアが未設定です。将来このファイルにモックが追加された際のテスト汚染を防ぐため、ファイル先頭付近に afterEach(() => jest.clearAllMocks()) を入れてください。
As per coding guidelines: "**/*.test.{ts,tsx}: テストの afterEach で jest.clearAllMocks() を呼び出してください".

🤖 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/hooks/tts/formatters.test.ts` around lines 1 - 11, Add a test teardown to
clear Jest mocks: in the test file (formatters.test.ts) near the top (just after
imports) add an afterEach callback that calls jest.clearAllMocks() so any mocks
added later won't leak between tests; ensure the statement uses afterEach(() =>
jest.clearAllMocks()) and is placed before any test definitions that use the
imported symbols like dedupeLinesByTtsName, formatFirstConnectedLineEnPhrase,
formatJrWestStopsListEn, replaceJapaneseText, stripParensForTTS, and
stripStationParensForTTS.

Source: Coding guidelines

🤖 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.

Inline comments:
In `@src/hooks/tts/formatters.ts`:
- Around line 160-163: The joinWithAnd function produces "A, and B" for two
items; update joinWithAnd to handle names.length === 2 as a special case and
return "A and B" (keep the existing behavior for 0 or 1 item and the current
comma-separated logic for 3+ items); reference the joinWithAnd(names: string[])
function and adjust its branching so it returns names[0] + ' and ' + names[1]
when names.length === 2.

---

Outside diff comments:
In `@src/hooks/tts/formatters.test.ts`:
- Around line 1-11: Add a test teardown to clear Jest mocks: in the test file
(formatters.test.ts) near the top (just after imports) add an afterEach callback
that calls jest.clearAllMocks() so any mocks added later won't leak between
tests; ensure the statement uses afterEach(() => jest.clearAllMocks()) and is
placed before any test definitions that use the imported symbols like
dedupeLinesByTtsName, formatFirstConnectedLineEnPhrase, formatJrWestStopsListEn,
replaceJapaneseText, stripParensForTTS, and stripStationParensForTTS.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8aa29146-f508-4b9d-afd4-3230d593b71c

📥 Commits

Reviewing files that changed from the base of the PR and between 178fcd6 and 3356c6c.

📒 Files selected for processing (6)
  • src/hooks/tts/formatters.test.ts
  • src/hooks/tts/formatters.ts
  • src/hooks/tts/templates.ts
  • src/hooks/useTTSText.bus.test.tsx
  • src/hooks/useTTSText.test.tsx
  • src/hooks/useTTSText.ts

Comment thread src/hooks/tts/formatters.ts Resolved
@TinyKitten
TinyKitten merged commit 0062f80 into dev Jun 10, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the claude/tts-official-theme-wording-0sw39z branch June 10, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants