Add segmented TTS metadata for mixed-language names#1432
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughText-to-Speech(TTS)メタデータをStation、StationMinimal、Line、TrainTypeエンドポイントに公開するため、名前のセグメント化APIを追加し、プロトバッファ型に対応するserde派生や DTO/インタラクタでの name_tts_segments 統合を行った。 Changes
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)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
# 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
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
stationapi/src/use_case/dto/station.rs (1)
189-191: セグメント[1]のpronunciationフィールドの検証が不足しています。
Rinkaiセグメントはsurface、fallback_text、separatorを検証していますが、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
📒 Files selected for processing (10)
AGENTS.mdstationapi/build.rsstationapi/protostationapi/src/domain/ipa.rsstationapi/src/use_case/dto.rsstationapi/src/use_case/dto/line.rsstationapi/src/use_case/dto/station.rsstationapi/src/use_case/dto/train_type.rsstationapi/src/use_case/dto/tts.rsstationapi/src/use_case/interactor/query.rs
Summary
Verification
Related
Summary by CodeRabbit
ドキュメント
新機能
テスト