Repository navigation
TTS合成をCloud Text-to-Speech Gemini TTSモデルに統一 - #5590
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughGoogle VertexAI/Google TTS から Gemini TTS へ移行し、GoogleAuth トークン取得を導入。不要な MP3 エンコーダ、IPA/SSML ユーティリティと関連テストを削除。フロントエンドに日本語音声選択を追加し、再生タイムアウトを延長。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client (App)
participant CF as Cloud Function (tts.ts)
participant Auth as GoogleAuth
participant Gemini as Gemini TTS API
participant Store as Firestore/Storage
participant PubSub as Pub/Sub (cache publish)
Client->>CF: TTS リクエスト (text, languageCode, voiceName, options)
CF->>Auth: アクセストークン取得
Auth-->>CF: access_token
CF->>Gemini: 音声合成リクエスト (token, ssml/text, modelName, options)
Gemini-->>CF: 合成オーディオ (raw bytes, mimeType?)
CF->>Store: キャッシュ用メタデータ保存/取得
CF->>PubSub: 合成完了ペイロード公開 (audio, mimeType, metadata)
CF-->>Client: 合成結果レスポンス (audioURL/bytes, mimeType, metadata)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
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)
Comment |
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/useTTS.ts (1)
90-102:⚠️ Potential issue | 🟠 Major旧AsyncStorageの音声名が無検証でGemini-TTSに送信され、アップグレード直後に合成が失敗します。
AsyncStorage に保存された旧Cloud TTS の voice id(例:
ja-JP-Standard-B、en-US-Standard-C)が、フロントエンドで無検証に復元され、バックエンドに送信されます。バックエンドは受け取った音声名をそのまま Gemini-TTS API に渡していますが、Gemini-TTS は 30個の事前定義された voice 名(Aoede、Achernar など)のみを受け入れるため、既存ユーザーがアップデート直後に合成を実行すると API エラーが発生します。復元時に既知の旧 voice id を Gemini 互換の名前へマイグレーションするか、許可リストでフィルタリングしてください。
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/useTTS.ts` around lines 90 - 102, The stored AsyncStorage voice ids (ASYNC_STORAGE_KEYS.TTS_JA_VOICE_NAME / ASYNC_STORAGE_KEYS.TTS_EN_VOICE_NAME) may be legacy Cloud TTS ids and must be validated/migrated before restoring into state; update the useEffect in useTTS.ts to pass loaded jaVoice/enVoice through a migration/validation step (e.g., call migrateOldVoiceIdToGemini(voice) which maps known legacy ids like "ja-JP-Standard-B" → "Aoede" or similar) and/or filter against a VOICE_ALLOWLIST (isAllowedGeminiVoice) and only set ttsJaVoiceName/ttsEnVoiceName if the result is a valid Gemini name, otherwise use '' or a safe default; add the helper mapping/allowlist functions/constants and ensure setTuning receives the migrated/validated names.
🧹 Nitpick comments (1)
functions/src/funcs/tts.ts (1)
209-218: キャッシュキーにプロンプトと言語コードも含めておくと安全です。今回の出力は
languageCodeとpromptに強く依存していますが、ハッシュ対象は text/voice/version だけです。将来ここを調整したときに version の上げ忘れで古い音声を返し続けるので、実際の合成パラメータをそのままキーに入れておく方が保守しやすいです。🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@functions/src/funcs/tts.ts` around lines 209 - 218, hashPayloadObj currently hashes {enModel: GEMINI_TTS_MODEL, enVoiceName, jaVoiceName, ssmlEn, ssmlJa, version} which misses the actual prompt and languageCode used for synthesis; update the payload used for hashing (the object assigned to hashPayloadObj referenced alongside hashAlgorithm and version) to include prompt and languageCode (and any other synthesis params like speakingRate/pitch if present) so the cache key uniquely reflects the real input parameters that affect output.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/hooks/useTTS.ts`:
- Around line 90-102: The stored AsyncStorage voice ids
(ASYNC_STORAGE_KEYS.TTS_JA_VOICE_NAME / ASYNC_STORAGE_KEYS.TTS_EN_VOICE_NAME)
may be legacy Cloud TTS ids and must be validated/migrated before restoring into
state; update the useEffect in useTTS.ts to pass loaded jaVoice/enVoice through
a migration/validation step (e.g., call migrateOldVoiceIdToGemini(voice) which
maps known legacy ids like "ja-JP-Standard-B" → "Aoede" or similar) and/or
filter against a VOICE_ALLOWLIST (isAllowedGeminiVoice) and only set
ttsJaVoiceName/ttsEnVoiceName if the result is a valid Gemini name, otherwise
use '' or a safe default; add the helper mapping/allowlist functions/constants
and ensure setTuning receives the migrated/validated names.
---
Nitpick comments:
In `@functions/src/funcs/tts.ts`:
- Around line 209-218: hashPayloadObj currently hashes {enModel:
GEMINI_TTS_MODEL, enVoiceName, jaVoiceName, ssmlEn, ssmlJa, version} which
misses the actual prompt and languageCode used for synthesis; update the payload
used for hashing (the object assigned to hashPayloadObj referenced alongside
hashAlgorithm and version) to include prompt and languageCode (and any other
synthesis params like speakingRate/pitch if present) so the cache key uniquely
reflects the real input parameters that affect output.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b32a0734-5b10-4afa-be74-269c3921df95
📒 Files selected for processing (7)
functions/src/funcs/tts.tsfunctions/src/utils/encodeMp3.tsfunctions/src/utils/legacyIpa.tssrc/components/TuningSettings.tsxsrc/hooks/useTTS.tssrc/utils/ssml.test.tssrc/utils/ssml.ts
💤 Files with no reviewable changes (4)
- functions/src/utils/legacyIpa.ts
- functions/src/utils/encodeMp3.ts
- src/utils/ssml.test.ts
- src/utils/ssml.ts
Summary
encodeMp3.ts,legacyIpa.ts,ssml.ts)を削除Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
新機能
改善
リファクタリング