Skip to content

英語TTSのプロンプト・CPU設定を調整し駅ナンバリングの発音を修正 - #5538

Merged
TinyKitten merged 3 commits into
devfrom
feature/improve-english-tts
Mar 8, 2026
Merged

TinyKitten merged 3 commits into
devfrom
feature/improve-english-tts

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Mar 8, 2026 •

Copy link
Copy Markdown
Member

Summary

  • 英語TTSのプロンプトを落ち着いた口調かつ早口めに更新
  • tts関数のCPUを2コアに設定
  • EN_GEMINI_VOLUME_BOOST_DB を8dBから6dBに戻す
  • 駅ナンバリングの数字を <say-as interpret-as="cardinal"> SSMLタグで囲み、1文字ずつではなく数値として発音されるように修正
  • Gemini TTS用の stripSsml に <say-as> タグのハンドリングを追加(数字を英単語に変換)

Test plan

  • 英語TTSの発音が落ち着いた口調かつ早口めになっていることを確認
  • 駅ナンバリング(例: JY-12)の数字が "twelve" と発音されることを確認
  • 各テーマでの英語TTS再生が正常に動作することを確認

🤖 Generated with Claude Code

Summary by CodeRabbit

リリースノート

  • バグ修正・改善

    • 英語の数字が音声でより自然な語として発音されるようになりました(SSMLによる明示的な読み上げ対応)。
    • 音声の出力音量を調整し、より適切な出力品質を実現しました。
    • 落ち着きのある、クリアで現代的なアナウンス調に改善。より速く、キレのある発話で不要な間を削減しました。
  • パフォーマンス最適化

    • 音声生成の処理リソース配分を見直しました。

@coderabbitai

coderabbitai Bot commented Mar 8, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

TTS機能でGemini向けプロンプトと音量定数を更新し、0–99の数字を英単語に変換するnumberToEnglishWord()を追加、SSMLでの<say-as interpret-as="cardinal">対応を拡張。Cloud FunctionのonCallにcpu: 2を追加し、useTTSTextで駅番号をsay-asでラップするよう変更しました。

Changes

Cohort / File(s) Summary
Gemini TTS設定 / 関数
functions/src/funcs/tts.ts
EN_GEMINI_VOLUME_BOOST_DBを8→6に変更。tts関数のonCallにcpu: 2を追加。Gemini向けプロンプトを拡張・再文言化。
SSML数値処理 / ヘルパー追加
functions/src/funcs/tts.ts
numberToEnglishWord(n)を追加し、SSMLの<say-as interpret-as="cardinal">N</say-as>を英語単語に変換して処理するロジックを拡張。
フロントエンド TTS テキスト
src/hooks/useTTSText.ts
nextStationNumberの出力で駅番号を<say-as interpret-as="cardinal">…</say-as>でラップするように変更(単一/複数トークン両対応)。
テスト更新
src/hooks/useTTSText.test.tsx
駅番号周りの期待文字列を<say-as interpret-as="cardinal">N</say-as>に合わせて修正。

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Func as CloudFunction\n(`functions/src/funcs/tts.ts`)
    participant Gemini as Gemini TTS

    Client->>Func: onCall TTSリクエスト (テキスト/SSML)
    Func-->>Func: SSML正規化・`numberToEnglishWord()`で<say-as>処理
    Func->>Gemini: 合成リクエスト (プロンプト, volume=EN_GEMINI_VOLUME_BOOST_DB)
    Gemini-->>Func: 音声バイナリ
    Func-->>Client: 音声を返却
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

概要

TTS機能の音声出力品質を改善するため、Geminiボリューム設定の調整、数字のEnglish単語変換、SSML処理の拡張、CPU割り当て追加、プロンプトテキスト改善、および駅番号の音声合成タグ化が実装されました。

変更内容

コホート / ファイル 概要
Gemini TTS設定・定数
functions/src/funcs/tts.ts
EN_GEMINI_VOLUME_BOOST_DB定数を8から6に変更。tts関数にcpu: 2のリソース割り当てを追加。
SSML数値処理
functions/src/funcs/tts.ts
numberToEnglishWord()ヘルパー関数を追加し、0~99の数字をEnglish単語に変換。<say-as interpret-as="cardinal">N</say-as>タグの処理に対応。
TTS生成プロンプト
functions/src/funcs/tts.ts
Gemini TTSプロンプトを拡張・改訂。落ち着き、明確さ、現代的な駅アナウンス風の配信を指示。
駅番号のSSML音声アノテーション
src/hooks/useTTSText.ts
nextStationNumberを<say-as interpret-as="cardinal">NUMBER</say-as>タグでラッピング。単一トークン、複数トークン両方に対応。

推定コード レビュー努力

🎯 3 (Moderate) | ⏱️ ~20分

関連する可能性のあるPR

推奨ラベル

react, functions

詩

🐰 駅の数字、ことばに変えて、
そっと告げるは明瞭な声。
say-as が跳ねるリズムで、
ボリュームは控えめに、速く、
小さなCPUも力を貸すよ。

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、English TTS プロンプトの調整、CPU設定の変更、駅ナンバリング発音の修正という、変更内容の主要な部分をすべて正確に反映しており、非常に具体的で明確です。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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 feature/improve-english-tts

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

🤖 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 26: 現在の変更(EN_GEMINI_VOLUME_BOOST_DB と line 372 の値)がキャッシュキーの id
計算に含まれていないため既存キャッシュが使われてしまいます。修正方法:tts のキャッシュキー(id を生成している関数/式、参照されている変数名例:
EN_GEMINI_VOLUME_BOOST_DB と該当の line372 にあるパラメータ)にこれらの定数/パラメータを含めるか、キャッシュ方式に使っている
version 値をインクリメントして確実に新しいプロンプト/音量が反映されるようにしてください。必ず id を生成している箇所(id を
return/保存する関数やキー生成ロジック)を更新し、既存キャッシュと衝突しないことを確認してください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f29b60af-f7fe-4aac-81fa-d611e72b241e

📥 Commits

Reviewing files that changed from the base of the PR and between ff72342 and b81549c.

📒 Files selected for processing (2)
  • functions/src/funcs/tts.ts
  • src/hooks/useTTSText.ts

Comment thread functions/src/funcs/tts.ts Resolved
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

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

🧹 Nitpick comments (1)
src/hooks/useTTSText.test.tsx (1)

132-132: 2桁の駅番号ケースも1本追加したいです。

今回の更新はすべて S-02 → <say-as ...>2</say-as> の確認に寄っているので、PR本文で例に出ている JY-12 のような 10–99 番台の回帰はまだ拾えません。useNumbering を 1 件だけ JY-12 でモックしたケースを足しておくと、今回の修正範囲をより直接守れます。

Also applies to: 144-144, 159-159, 171-171, 186-186, 198-198, 213-213, 225-225, 240-240, 252-252, 267-267, 279-279, 294-294, 314-326

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useTTSText.test.tsx` at line 132, Add a test that covers two-digit
station numbers (e.g., "JY-12") by mocking useNumbering once to return a
two-digit station id and expected markup, similar to existing S-02 cases; locate
the tests in useTTSText.test.tsx and update the relevant test block(s) that
currently only assert single-digit conversion (references: useNumbering mock and
the test cases around the existing 'S-02' assertions) so the suite verifies
10–99 numbering is converted to <say-as ...>12</say-as>-style output as well.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/hooks/useTTSText.test.tsx`:
- Line 132: Add a test that covers two-digit station numbers (e.g., "JY-12") by
mocking useNumbering once to return a two-digit station id and expected markup,
similar to existing S-02 cases; locate the tests in useTTSText.test.tsx and
update the relevant test block(s) that currently only assert single-digit
conversion (references: useNumbering mock and the test cases around the existing
'S-02' assertions) so the suite verifies 10–99 numbering is converted to <say-as
...>12</say-as>-style output as well.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c085dd5b-05b1-461f-96fc-8944ddc832c5

📥 Commits

Reviewing files that changed from the base of the PR and between b81549c and df7a15f.

📒 Files selected for processing (1)
  • src/hooks/useTTSText.test.tsx

@TinyKitten
TinyKitten merged commit bc65d1e into dev Mar 8, 2026
5 checks passed
@TinyKitten
TinyKitten deleted the feature/improve-english-tts branch March 8, 2026 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant