Skip to content

TTSの日英両言語をAzure HD(DragonHD)ボイスに対応 - #6275

Merged
TinyKitten merged 3 commits into
devfrom
claude/elegant-sagan-lwdk5u
Jun 18, 2026
Merged

TinyKitten merged 3 commits into
devfrom
claude/elegant-sagan-lwdk5u

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Jun 18, 2026 •

Copy link
Copy Markdown
Member

概要

TTS(Azure Speech)の日本語・英語の両言語を、標準ニューラルボイスから Azure HD(DragonHD)ボイスへ切り替えます。あわせて HD ボイスが非対応の SSML 要素(<prosody> / <mstts:express-as>)をビルダー側で出し分け、HD 提供リージョンへエンドポイントを合わせます。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • ボイス名を HD(DragonHD)へ変更(wrangler.jsonc の dev / production 両方)
    • 日本語: ja-JP-NanamiNeural → ja-JP-Nanami:DragonHDLatestNeural
    • 英語: en-US-JennyNeural → en-US-Jenny:DragonHDLatestNeural
  • HD ボイス判定 isAzureHdVoiceName() を src/utils/ttsVoice.ts に追加(:DragonHD...Neural を検出)
  • src/lib/azure/tts.ts の buildAzureSsml を HD 対応化。HD ボイスでは非対応の <prosody> / <mstts:express-as> を出力しない(言語ごとにボイス解決されるため片方だけ HD でも安全)。テスト容易化のためビルダーを export
  • AZURE_TTS_RATE および rate オプションを廃止(HD は <prosody> 非対応で、そもそもレート操作の必要性が薄いため)。Env.AZURE_TTS_RATE 型・ルートの受け渡し・TtsOptions.rate・ビルダーの rate 生成を削除
  • Azure Speech リージョンを japaneast → southeastasia へ変更。HD(DragonHD)ボイスは japaneast で提供されておらず、最寄りの HD 提供リージョンが Southeast Asia のため
  • テスト追加: HD 判定・HD ボイス名の妥当性(ttsVoice.test.ts)、HD/標準で SSML 装飾を出し分けつつ say-as 等の本文は保持すること(新規 tts.test.ts)

Important

マージ後、Azure 側で以下の対応が別途必要です(コードだけでは 400 が解消しません)。

  1. Southeast Asia リージョンに Speech リソースを作成
  2. AZURE_SPEECH_KEY シークレットを新リソースのキーへ差し替え(dev / production それぞれ wrangler secret put AZURE_SPEECH_KEY)。キーはリージョン紐付けのため、japaneast のキーでは新エンドポイントに認証できません

テスト

  • npm run lint が通ること
  • npm test が通ること
  • npm run typecheck が通ること

functions/ ディレクトリで実行し、いずれも成功(npm test: 6 suites / 50 tests passed)。

関連Issue

スクリーンショット(任意)


Generated by Claude Code

Summary by CodeRabbit

リリースノート

  • New Features

    • DragonHDボイスのサポートを追加しました。より高品質なテキスト読み上げが利用可能になります。
  • Chores

    • Azure TTS設定を更新。サービスリージョンとボイス設定を最適化しました。
    • 一部のTTSパラメータ設定を簡潔にしました。

@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

ウォークスルー

Azure TTS に DragonHD ボイス判定(isAzureHdVoiceName)を追加し、buildAzureSsml で HD ボイスの場合は <prosody> および <mstts:express-as> を付与しない分岐を実装。rate オプションを TtsOptions・Env・設定ファイルから全面削除し、ボイス名を DragonHDLatestNeural 系に更新した。

変更点

DragonHD ボイス対応

レイヤー / ファイル 概要
HD ボイス判定ユーティリティと型定義
functions/src/utils/ttsVoice.ts, functions/src/types.ts
ttsVoice.ts に :DragonHD...Neural パターン定数と isAzureHdVoiceName 関数を新規追加。types.ts の Env インターフェースから AZURE_TTS_RATE プロパティを削除。
buildAzureSsml の HD 分岐と rate 削除
functions/src/lib/azure/tts.ts
isAzureHdVoiceName をインポートし、TtsOptions から rate を削除。buildAzureSsml を export 化し、HD ボイスでは <prosody>/<mstts:express-as> を付与しない分岐を実装。非 HD では pitch・style が指定された場合のみ装飾を適用。
TTS ルートと設定ファイルの更新
functions/src/routes/tts.ts, functions/wrangler.jsonc
ttsOptions から rate を削除。wrangler.jsonc の dev/production 両環境でリージョンを southeastasia に変更し、AZURE_TTS_RATE を削除、ボイス名を DragonHDLatestNeural 系に置換。
テストの追加・拡張
functions/src/utils/ttsVoice.test.ts, functions/src/lib/azure/tts.test.ts
ttsVoice.test.ts に isAzureHdVoiceName の受理・非受理ケースを追加。tts.test.ts を新規作成し、通常ボイルでの pitch/style 埋め込みと HD ボイルでの装飾抑制・内側 SSML 保持を検証。

推定コードレビュー工数

🎯 3 (Moderate) | ⏱️ ~20 分

関連する可能性のある PR

  • TrainLCD/MobileApp#6238: Azure TTS の SSML 生成・型定義を初期実装した PR で、今回変更された buildAzureSsml および TtsOptions の直接の前身となっている。

提案ラベル

functions

詩

🐇 ドラゴンHDの声、滑らかに流れ
prosody なんていらない、それが新しい掟
rate さようなら、southeastasia へ飛ぶ
テストで証明、HDは装飾なし
うさぎも跳ねる、新しいボイスで ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは、プルリクエストの主要な変更内容を明確に要約しており、TTS システムを標準ニューラルボイスから Azure HD(DragonHD)ボイスへ移行する旨が適切に表現されています。
Description check ✅ Passed プルリクエストの説明は、テンプレートの全ての必須セクション(概要、変更の種類、変更内容、テスト)を網羅しており、各セクションが適切に記入されています。変更の詳細、実施したテスト内容、重要な事後対応の注意も記載されています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/elegant-sagan-lwdk5u

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

@TinyKitten TinyKitten self-assigned this Jun 18, 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
functions/src/lib/azure/tts.test.ts (1)

3-57: ⚠️ Potential issue | 🟡 Minor

afterEach ブロックで jest.clearAllMocks() を追加してください。

テストスイート全体で共通のクリアを入れることで、今後 jest.mock を追加した際の副作用を抑えられます。

修正例
 describe('buildAzureSsml', () => {
+  afterEach(() => {
+    jest.clearAllMocks();
+  });
+
   it('wraps standard neural voices with prosody/style when provided', () => {

コーディングガイドライン「テストの afterEach で jest.clearAllMocks() を呼び出してください」に対応する必要があります。

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@functions/src/lib/azure/tts.test.ts` around lines 3 - 57, Add an afterEach
hook inside the describe('buildAzureSsml') block that calls jest.clearAllMocks()
to ensure mocks are properly cleared between test cases. This hook should be
placed at the end of the describe block, after all the test cases (it()
statements) that test the buildAzureSsml function.

Source: Coding guidelines

functions/src/utils/ttsVoice.test.ts (1)

7-67: ⚠️ Potential issue | 🟡 Minor

afterEach で jest.clearAllMocks() を追加してください。

現状のテストは動作していますが、ガイドラインに従い、テストブロック内に afterEach を追加してモック状態のリセットを明示的に行う必要があります。将来モックが追加された際のテスト間汚染を防ぐための保守性向上対策です。

修正例
 describe('ttsVoice (Azure)', () => {
+  afterEach(() => {
+    jest.clearAllMocks();
+  });
+
   it('accepts Azure neural voices', () => {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@functions/src/utils/ttsVoice.test.ts` around lines 7 - 67, Add an afterEach
hook inside the describe block for 'ttsVoice (Azure)' that calls
jest.clearAllMocks() to explicitly reset mock state between test executions.
This hook should be placed after the describe statement and before the test
cases to ensure consistent test isolation and prevent potential mock pollution
when mocks are added in the future.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@functions/src/lib/azure/tts.test.ts`:
- Around line 3-57: Add an afterEach hook inside the describe('buildAzureSsml')
block that calls jest.clearAllMocks() to ensure mocks are properly cleared
between test cases. This hook should be placed at the end of the describe block,
after all the test cases (it() statements) that test the buildAzureSsml
function.

In `@functions/src/utils/ttsVoice.test.ts`:
- Around line 7-67: Add an afterEach hook inside the describe block for
'ttsVoice (Azure)' that calls jest.clearAllMocks() to explicitly reset mock
state between test executions. This hook should be placed after the describe
statement and before the test cases to ensure consistent test isolation and
prevent potential mock pollution when mocks are added in the future.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3621474a-19a9-4cf2-8178-30c8d718524b

📥 Commits

Reviewing files that changed from the base of the PR and between 95c5650 and c7c7ad1.

📒 Files selected for processing (7)
  • functions/src/lib/azure/tts.test.ts
  • functions/src/lib/azure/tts.ts
  • functions/src/routes/tts.ts
  • functions/src/types.ts
  • functions/src/utils/ttsVoice.test.ts
  • functions/src/utils/ttsVoice.ts
  • functions/wrangler.jsonc
💤 Files with no reviewable changes (2)
  • functions/src/types.ts
  • functions/src/routes/tts.ts

Copy link
Copy Markdown
Member Author

@coderabbitai afterEach(jest.clearAllMocks) の提案は、今回は見送ります。

理由:

  • 追加した 2 ファイル(tts.test.ts / ttsVoice.test.ts)はいずれも純粋関数のテストで、jest.mock を一切使っていません。clearAllMocks は実質 no-op です。
  • functions/ 配下のテストは全ファイルが jest.mock を使っておらず、afterEach/clearAllMocks を持つファイルも 1 つもありません(normalize.test.ts ほか同様)。追加すると既存の慣習から外れた無意味なボイラープレートになります。
  • CLAUDE.md のガイドラインも「jest.mock でモックする層がある場合に afterEach で clearAllMocks を呼ぶ」という文脈であり、モックを使わない本テストは対象外と解釈しています。

将来この層でモックを導入する際には、その時点で afterEach(() => jest.clearAllMocks()) をセットで入れます。


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@TinyKitten ご説明ありがとうございます。おっしゃる通りです。純粋関数のテストで jest.mock を使用しない場合、afterEach(jest.clearAllMocks) は実質 no-op であり、既存の慣習とも合っていません。提案を取り下げます。

🐇


✏️ Learnings added
Learnt from: TinyKitten
URL: https://github.com/TrainLCD/MobileApp/pull/6275

Timestamp: 2026-06-18T14:17:29.107Z
Learning: In the TrainLCD/MobileApp repository, test files under `functions/` that test pure functions without any `jest.mock` usage do not include `afterEach`/`clearAllMocks` boilerplate. The convention is to only add `afterEach(() => jest.clearAllMocks())` when `jest.mock` is actually used in the test file. Existing test files like `normalize.test.ts` follow the same pattern.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@TinyKitten
TinyKitten merged commit c6932a0 into dev Jun 18, 2026
4 checks passed
@TinyKitten
TinyKitten deleted the claude/elegant-sagan-lwdk5u branch June 18, 2026 14:17
@TinyKitten TinyKitten mentioned this pull request Jun 18, 2026
4 of 9 tasks
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.

2 participants