Skip to content

Add segmented TTS metadata for mixed-language names#1432

Merged
TinyKitten merged 7 commits into
devfrom
fix/ipa-meitetsu-stations
Mar 15, 2026
Merged

Add segmented TTS metadata for mixed-language names#1432
TinyKitten merged 7 commits into
devfrom
fix/ipa-meitetsu-stations

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Mar 15, 2026

Copy link
Copy Markdown
Member

Summary

  • add segmented TTS metadata for Station, StationMinimal, Line, and TrainType
  • preserve existing IPA fields while introducing per-token TTS segments for mixed-language names
  • update the gRPCProto submodule and IPA handling to support mixed-language TTS construction

Verification

  • cargo fmt --check
  • SQLX_OFFLINE=true cargo build -p stationapi
  • SQLX_OFFLINE=true cargo test -p stationapi

Related

Summary by CodeRabbit

  • ドキュメント

    • TTS メタデータ公開に関する説明を追加
  • 新機能

    • Station、StationMinimal、Line、TrainType が name_tts_segments を公開し、各セグメント単位の発音データ(表記、フォールバック、発音、言語、区切り)を取得可能に
  • テスト

    • 混在言語の駅名に対する TTS セグメント分割の検証テストを追加

@github-actions github-actions Bot added the fix 直した label Mar 15, 2026
@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown
Contributor

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: ae0df02c-81f1-4ce9-bc65-078248de3ea0

📥 Commits

Reviewing files that changed from the base of the PR and between 6af58fc and 8fc46e0.

📒 Files selected for processing (3)
  • stationapi/src/domain/ipa.rs
  • stationapi/src/use_case/dto/line.rs
  • stationapi/src/use_case/dto/station.rs

📝 Walkthrough

Walkthrough

Text-to-Speech(TTS)メタデータをStation、StationMinimal、Line、TrainTypeエンドポイントに公開するため、名前のセグメント化APIを追加し、プロトバッファ型に対応するserde派生や DTO/インタラクタでの name_tts_segments 統合を行った。

Changes

Cohort / File(s) Summary
ドキュメント更新
AGENTS.md
gRPC エンドポイント概要に TTS メタデータ公開(name_tts_segments)についての記述を追加。
ビルド設定
stationapi/build.rs
生成型 TtsAlphabetTtsSegmentSerialize/Deserialize 派生属性を追加。
Protoサブモジュール
stationapi/proto
サブプロジェクトのコミットポインタを更新。
IPA/TTS コア処理
stationapi/src/domain/ipa.rs
駅名→IPA パイプラインをセグメントベースへリファクタ。TtsAlphabetKind/TtsNameSegment 型と station_name_to_tts_segments を追加し、セグメント単位での発音データ生成を実装。
DTO モジュール公開
stationapi/src/use_case/dto.rs
新規 pub mod tts; を公開。
DTO 変換処理
stationapi/src/use_case/dto/line.rs, stationapi/src/use_case/dto/station.rs, stationapi/src/use_case/dto/train_type.rs
各エンティティの gRPC 変換に name_tts_segments を追加し、station_name_to_tts_segmentsto_proto_tts_segments を用いて設定。
TTS 変換ユーティリティ
stationapi/src/use_case/dto/tts.rs
Vec<TtsNameSegment>Vec<TtsSegment> に変換する to_proto_tts_segments を追加。
クエリ/インタラクタ
stationapi/src/use_case/interactor/query.rs
get_routesget_routes_minimal で TTS セグメントを計算し、StationMinimalname_tts_segments を設定。

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Interactor as UseCase/Interactor
  participant Domain as domain::ipa
  participant DTO as use_case::dto
  participant Proto as generated::proto

  Client->>Interactor: get_routes / get_routes_minimal
  Interactor->>Domain: station_name_to_tts_segments(name_k, name_r)
  Domain-->>Interactor: Vec<TtsNameSegment>
  Interactor->>DTO: to_proto_tts_segments(segments)
  DTO-->>Interactor: Vec<TtsSegment>
  Interactor->>Proto: build Station/Line/TrainType with name_tts_segments
  Interactor-->>Client: gRPC response (includes name_tts_segments)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

feature

Poem

🐰 セグメントひとつずつ ことばをつなぎ
英語も日本語も リズムに乗せて
駅の名前が 小さな歌になる
ピョンと跳ねて、声が届くよ 🎶

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、変更内容の主要な目的を明確に反映しており、混合言語名向けのセグメント化されたTTSメタデータ追加という中心的な変更を正確に要約しています。

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ipa-meitetsu-stations
📝 Coding Plan
  • Generate coding plan for human review comments

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

# Conflicts:
#	stationapi/src/domain/ipa.rs
#	stationapi/src/use_case/dto/line.rs
#	stationapi/src/use_case/dto/station.rs
#	stationapi/src/use_case/dto/train_type.rs
@TinyKitten TinyKitten self-assigned this Mar 15, 2026

@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: 2

🧹 Nitpick comments (1)
stationapi/src/use_case/dto/station.rs (1)

189-191: セグメント[1]のpronunciationフィールドの検証が不足しています。

Rinkaiセグメントはsurfacefallback_textseparatorを検証していますが、pronunciationの検証がありません。他のセグメントと同様に、このフィールドも検証することで、TTSセグメント生成ロジックのより完全なカバレッジが得られます。

💡 pronunciationアサーションの追加提案
         assert_eq!(grpc_station.name_tts_segments[1].surface, "Rinkai");
         assert_eq!(grpc_station.name_tts_segments[1].fallback_text, "りんかい");
+        assert_eq!(grpc_station.name_tts_segments[1].pronunciation, "ɾiŋka.i"); // 期待される発音を確認してください
         assert_eq!(grpc_station.name_tts_segments[1].separator, " ");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@stationapi/src/use_case/dto/station.rs` around lines 189 - 191, テストで
grpc_station の TTS セグメント検証が抜けているため、name_tts_segments[1] の pronunciation
フィールドも検証するアサーションを追加してください(対象は
grpc_station.name_tts_segments[1].pronunciation);期待値は既存のテストデータ/他のセグメントで使っている発音フォーマットに合わせて設定し、Rinkai
セグメントの surface/fallback_text/separator と同様に確実に比較するようにします。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@stationapi/src/domain/ipa.rs`:
- Around line 255-263: The code computes stem_len from normalized byte lengths
and slices original by that byte index, which can split UTF-8 chars; instead
compute the stem boundaries in characters and map to a byte index in original:
determine stem_char_count = normalized.chars().count() - suffix.chars().count()
(or find the char-index where suffix begins), then get the byte offset in
original via original.char_indices().nth(stem_char_count).map(|(i,_)|
i).unwrap_or(original.len()) and use that byte offset for
&original[..byte_offset]; then pass that safe UTF-8 stem to
word_to_tts_segments(stem) and leave suffix handling unchanged (references:
JAPANESE_SUFFIXES, normalized, original, stem_len, word_to_tts_segments).

In `@stationapi/src/use_case/dto/line.rs`:
- Around line 20-23: name_tts_segments
のフォールバックが無効になっているので、station_name_to_tts_segments
に空文字列を渡すのではなくカタカナフォールバック用の値を渡してください: 修正箇所は
to_proto_tts_segments(station_name_to_tts_segments(...)) の呼び出しで、第一引数の "" を
line.line_name_k に差し替え、line.line_name_r はそのまま第二引数に渡してカタカナフォールバックを有効にしてください(参照:
name_tts_segments, station_name_to_tts_segments, line.line_name_k,
line.line_name_r)。

---

Nitpick comments:
In `@stationapi/src/use_case/dto/station.rs`:
- Around line 189-191: テストで grpc_station の TTS
セグメント検証が抜けているため、name_tts_segments[1] の pronunciation
フィールドも検証するアサーションを追加してください(対象は
grpc_station.name_tts_segments[1].pronunciation);期待値は既存のテストデータ/他のセグメントで使っている発音フォーマットに合わせて設定し、Rinkai
セグメントの surface/fallback_text/separator と同様に確実に比較するようにします。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a1b60049-1777-46bf-a8db-e389e6c33b4b

📥 Commits

Reviewing files that changed from the base of the PR and between f80be56 and 6af58fc.

📒 Files selected for processing (10)
  • AGENTS.md
  • stationapi/build.rs
  • stationapi/proto
  • stationapi/src/domain/ipa.rs
  • stationapi/src/use_case/dto.rs
  • stationapi/src/use_case/dto/line.rs
  • stationapi/src/use_case/dto/station.rs
  • stationapi/src/use_case/dto/train_type.rs
  • stationapi/src/use_case/dto/tts.rs
  • stationapi/src/use_case/interactor/query.rs

Comment thread stationapi/src/domain/ipa.rs
Comment thread stationapi/src/use_case/dto/line.rs
@TinyKitten TinyKitten merged commit a1c4253 into dev Mar 15, 2026
11 checks passed
@TinyKitten TinyKitten deleted the fix/ipa-meitetsu-stations branch March 15, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix 直した

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant