TTS合成をNeural2に切り替え、nameIpa削除、バリデーション強化#5598
Merged
TinyKitten merged 1 commit intodevfrom Mar 15, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
📝 WalkthroughWalkthroughTTS(テキスト音声合成)バックエンドを Gemini から Neural2 に移行し、プロンプト機能を削除。GraphQL 型に IPA表記フィールドを追加し、言語別の音声設定を導入。TTS テンプレートに音素ラッピング機能を実装。 Changes
Sequence DiagramsequenceDiagram
actor User
participant React as React Component<br/>(useTTSText)
participant Hook as TTS Hook<br/>(useTTS)
participant Cache as Cache &<br/>Fetcher
participant Function as Cloud Function<br/>(functions/tts)
participant API as Text-to-Speech API<br/>(Neural2)
User->>React: Trigger announcement
React->>React: Generate TTS text<br/>with wrapPhoneme(nameRoman, nameIpa)
React->>Hook: Fetch speech audio<br/>(voiceName, ssml only)
Hook->>Cache: Check cache key<br/>(voice, ssml, version)
alt Cache Hit
Cache-->>Hook: Cached audio
else Cache Miss
Hook->>Function: POST with ssml payload<br/>(no prompts)
Function->>Function: Validate text byte limit<br/>per language
Function->>Function: Build ssml with<br/>phoneme tags
Function->>API: synthesizeWithNeural2<br/>(ssml, voiceName)
API-->>Function: Audio bytes
Function-->>Hook: Audio response
Hook->>Cache: Store in cache<br/>(version: 11)
end
Cache-->>React: Audio stream
React-->>User: Play announcement
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
Contributor
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@functions/src/funcs/tts.ts`:
- Line 139: The code currently passes client-provided raw SSML (input.ssml /
ssml: text) directly to the TTS synth without sanitization; update the TTS
path(s) (references: input.ssml, variable text and the call sites around the
noted ranges 139, 245-258, 338-339) to validate and enforce a strict SSML
policy: parse the SSML server-side (XML/HTML parser), enforce a tag/attribute
allowlist, strip or reject any disallowed tags/attributes, and enforce a
byte-length limit (and overall visible-text non-empty check) before forwarding
to the synth; for trusted flows consider building canonical SSML server-side
instead of trusting raw input and return a clear validation error for rejects.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4010b522-83b1-41b4-bd51-5492c03ccc96
📒 Files selected for processing (18)
functions/src/funcs/tts.tssrc/@types/graphql.d.tssrc/__fixtures__/line.tssrc/components/TuningSettings.tsxsrc/constants/asyncStorage.tssrc/constants/tts.tssrc/hooks/useGetStationsWithTermination.test.tsxsrc/hooks/useRefreshStation.test.tsxsrc/hooks/useTTS.tssrc/hooks/useTTSText.tssrc/hooks/useTransferLinesFromStation.test.tsxsrc/lib/graphql/queries.tssrc/store/atoms/tuning.tssrc/utils/__fixtures__/search.tssrc/utils/jr.tssrc/utils/phoneme.tssrc/utils/test/factories.tssrc/utils/ttsSpeechFetcher.ts
💤 Files with no reviewable changes (1)
- src/constants/asyncStorage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ja-JP-Neural2-B、EN:en-US-Neural2-F)getTtsConfigにエラー時キャッシュフォールバックを導入wrapPhonemeにXMLエスケープを追加しSSMLインジェクションを防止Test plan
npm run typecheckパスnpm run lintパスnpm test全137 suites / 1281 tests パス🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
新機能
変更