Skip to content

feat: VITS2アーキテクチャ改良の導入(音質向上+モデルサイズ34%削減) - #240

Closed
ayutaz wants to merge 16 commits into
devfrom
feat/vits2-upgrade
Closed

feat: VITS2アーキテクチャ改良の導入(音質向上+モデルサイズ34%削減)#240
ayutaz wants to merge 16 commits into
devfrom
feat/vits2-upgrade

Conversation

@ayutaz

@ayutaz ayutaz commented Mar 14, 2026

Copy link
Copy Markdown
Owner

Summary

VITS2論文 (arXiv:2307.16430) の改良4点を実装。推論速度・モデルサイズを維持しつつ音質向上を目指す。
Transformer Flowはモバイル/ラズパイ制約により導入しない。

1. Noise-Scaled MAS(学習改善、MOS +0.15)

  • MASコスト行列にガウスノイズを追加し、学習初期のアライメント探索を多様化
  • 5,000ステップで自動減衰、推論に影響なし
  • --mas-noise-start 0.01 --mas-noise-decay 2e-6

2. Mel Posterior Encoder(学習効率化)

  • Posterior Encoder (enc_q) の入力をLinear Spec (513ch) → Mel Spec (80ch) に変更
  • 学習時のみ使用されるモジュールのため推論に影響なし
  • --mel-posterior-encoder

3. SDP→DP切替 + DurationDiscriminatorV2(MOS +0.14、推論速度+10-20%)

  • Stochastic Duration Predictor → 決定的Duration Predictorに切替(推論軽量化)
  • GAN的Duration判別器で品質補償(~556Kパラメータ、学習時のみ)
  • 3オプティマイザ構成(Generator / Discriminator / Duration Discriminator)
  • --no-sdp --use-duration-discriminator

4. gin_channels 768→256(モデルサイズ -25MB、-34%)

  • マルチスピーカーの話者埋め込み次元を削減
  • 20話者では256次元で十分な表現力
  • --gin-channels(デフォルト256に変更)

5. Speaker-Conditioned TextEncoder(話者類似度 +0.20)

  • TextEncoderの第3 Transformer層に話者ベクトルを条件付け
  • 推論グラフへの追加はConv1d 1層のみ(+0.05MB)
  • --speaker-conditioned-encoder

コードレビューによるバグ修正

10エージェントによる批判的レビューで発見された7件の重大バグを修正:

  • LRスケジューラのstep()が呼ばれていない問題
  • MASノイズスケールがチェックポイントに保存されない問題(register_buffer化)
  • eval時にMASノイズが減衰・注入される問題(self.trainingガード)
  • DurationDiscriminatorV2のマスク適用漏れ
  • DDP時のインスタンス変数による状態受け渡しの安全性問題
  • mel変換のsampling_rateハードコード
  • SDP+DurationDiscriminator併用時の設定ミス検出

新規CLIフラグ

フラグ デフォルト 説明
--mas-noise-start 0.01 MASノイズ初期値
--mas-noise-decay 2e-6 MASノイズ減衰量/ステップ
--mel-posterior-encoder off Mel Posterior Encoder有効化
--no-sdp off SDP→DP切替
--use-duration-discriminator off Duration Discriminator有効化(--no-sdp必須)
--speaker-conditioned-encoder off Speaker-Conditioned TextEncoder有効化

推定改善効果

指標 改善量
MOS (自然性) +0.09〜+0.29
話者類似度 +0.20
推論速度 +10-20% (SDP→DP)
モデルサイズ 74MB → 49MB (-34%)

変更量

  • 13ファイル変更: +2,318行, -35行
  • 5テストファイル新規作成: 36テスト
  • 後方互換性: 全VITS2機能はデフォルト無効、既存の学習コマンドはそのまま動作

Test plan

  • 全ファイルの構文チェック・ruff format通過
  • DurationDiscriminatorV2の順伝播・形状テスト(7テスト)
  • SynthesizerTrn dur_info統合テスト(5テスト)
  • Noise-Scaled MAS減衰・state_dict保存テスト(8テスト)
  • Mel Posterior Encoder入出力形状テスト(5テスト)
  • gin_channels=256 モデル構築・推論テスト(5テスト)
  • Speaker-Conditioned TextEncoderテスト(11テスト)
  • 10エージェントによる批判的コードレビュー完了
  • GPU環境での統合テスト(フル学習200 epoch)

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 14, 2026 13:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces VITS2 architecture improvements (from arXiv:2307.16430) to the piper-plus TTS system in phases. The changes add noise-scaled MAS, mel posterior encoder, duration discriminator, speaker-conditioned text encoder, and gin_channels optimization — all behind feature flags for backward compatibility.

Changes:

  • Added 5 VITS2 features (Noise-Scaled MAS, Mel Posterior Encoder, SDP→DP switch, DurationDiscriminatorV2, Speaker-Conditioned TextEncoder) with CLI flags, all disabled by default
  • Reduced default gin_channels from 768/512 to 256 for multi-speaker models, targeting ~34% model size reduction
  • Added comprehensive test coverage (5 test files, 36+ tests) and detailed research documentation

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/python/piper_train/vits/models.py Core VITS2 changes: DurationDiscriminatorV2 class, noise-scaled MAS, mel posterior encoder, speaker-conditioned encoder, dur_info return
src/python/piper_train/vits/attentions.py Speaker conditioning injection in Encoder's middle layer
src/python/piper_train/vits/lightning.py 3-optimizer training loop, duration discriminator training, LR scheduler stepping, gin_channels default change
src/python/piper_train/vits/config.py Default gin_channels 512→256 for multi-speaker
src/python/piper_train/main.py CLI flags for all VITS2 features, argument mapping
src/python/piper_train/export_onnx.py Updated inference to pass speaker embedding to encoder
src/python/tests/test_*.py (5 files) Unit tests for all new features
docs/research/vits2-implementation-plan.md Detailed research and implementation plan
docs/README.md Link to research doc

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/research/vits2-implementation-plan.md Outdated
Comment thread src/python/piper_train/vits/models.py Outdated
@ayutaz ayutaz self-assigned this Mar 14, 2026
@ayutaz ayutaz changed the title feat: VITS2アーキテクチャ導入(Phase 1-3 + レビュー修正) feat: VITS2アーキテクチャ改良の導入(音質向上+モデルサイズ34%削減) Mar 14, 2026
@ayutaz
ayutaz force-pushed the feat/vits2-upgrade branch 2 times, most recently from 2d318b4 to 3bcf43a Compare March 18, 2026 14:45
@ayutaz
ayutaz marked this pull request as draft March 19, 2026 13:57
@ayutaz
ayutaz force-pushed the feat/vits2-upgrade branch from 0b31e5b to c30fd55 Compare March 20, 2026 08:19
ayutaz and others added 15 commits April 4, 2026 02:08
VITS2の5改良を推論グラフ影響で分類し、モバイル/ラズパイ制約下での
導入判定を実施。Noise-Scaled MAS・敵対的DP・Mel Posterior Encoderを
推論影響ゼロで導入推奨、Transformer Flowはサイズ増のため非推奨と判定。
VITS2以降のTTS動向(Flow Matching系、LLM+Codec系)も整理。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
一から学習する前提で再評価。gin_channels 768→256で推論サイズ-25MB、
SDP→DP切替で推論速度+10-20%向上を追加。Style-Bert-VITS2が
Duration Discriminatorを不安定で削除した事例を警告として記載。
推論モデルサイズ: 74MB→49MB (-34%) の軽量化見込み。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gin_channels削減・SDP→DP切替・Duration Discriminatorの各項目に
精度への影響と注意点を注釈として追加。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
導入ロードマップを具体的な実装マイルストーンに置き換え:
- Phase 1: Noise-Scaled MAS (M1) + Mel Posterior Encoder (M2)
- Phase 2: SDP→DP + Duration Discriminator (M3)
- Phase 3: gin_channels 768→256 (M4) + Speaker-Cond TextEncoder (M5)
- Phase 4: 統合学習・ONNX変換・品質評価 (M6)

各マイルストーンに対象ファイル・行番号・実装コード例・CLIフラグ・
完了条件チェックリスト・リスク評価・依存関係を記載。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
M1: MASコスト行列にガウスノイズを注入し学習初期のアライメント探索を多様化 (MOS +0.15)
M2: enc_qの入力をLinear Spec (513ch) → Mel Spec (80ch) に切替可能に (学習効率化)

両改良とも推論グラフに影響なし(学習時のみ使用)。
CLI: --mas-noise-start, --mas-noise-decay, --mel-posterior-encoder

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
M3-A: --no-sdp フラグでDuration Predictorを決定的DPに切替(推論速度+10-20%)
M3-B: DurationDiscriminatorV2を追加し、実/予測durationをGAN的に判別(MOS +0.14)
  - 3オプティマイザ構成(gen, disc, dur_disc)
  - Generator adversarial loss + L2 duration lossの併用で安定化
  - --use-duration-discriminator フラグで有効化
  - dur_infoにx(prosodyなし192ch)を返しin_channels不整合を修正

CLI: --no-sdp, --use-duration-discriminator

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…coder

M4: マルチスピーカーのデフォルトgin_channelsを768→256に変更(モデルサイズ-25MB, -34%)
M5: TextEncoderの第3層に話者ベクトルを条件付け(話者類似度+0.20)
    - attentions.py Encoderにcond_proj追加、forward/inferでg計算をenc_p前に移動
    - export_onnx.pyのinfer_forward()も同様に対応

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
C1: LRスケジューラのstep()をon_train_epoch_end()で明示的に呼出し
C2: current_mas_noise_scaleをregister_bufferに変更(state_dict保存対応)
C3: eval mode時のノイズスケール減衰を防止(self.trainingガード追加)
C4: config.pyのgin_channelsデフォルトを512→256に統一
C5: DurationDiscriminatorV2のdropout/ReLU後にマスク再適用
C6: spec_to_mel_torchのsampling_rateをhparamsから取得
C7: DDP安全のためdur_info等をインスタンス変数→直接引数渡しに変更
W6: SDP+DurationDiscriminator併用を警告→エラーに変更

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- docs: gin_channels=512→256にドキュメント更新
- models.py: MASノイズ注入もself.trainingガードで囲み、validation時の安定性を向上

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
バグ修正:
- infer()のenc_p重複呼び出しを削除 (float tensor embedding error)
- TextEncoderのgin_channels引数をenc_p_ginに修正
- lightning.pyのmerge conflictマーカー除去
- test_noise_scaled_mas: FP32累積誤差の許容値拡大
- test_duration_discriminator: マスクテストのatol緩和

学習高速化:
- Fused AdamW (全optimizer, CUDA時自動有効)
- CosineAnnealingLR + LinearLR warmup (--cosine-scheduler, --warmup-epochs)
- DDP bucket_cap_mb=50 (PCIe allreduce最適化)
- batch-size 32, max_epochs 60 推奨 (CLI変更のみ)
ruff F811: 同一メソッドが346行目と926行目で重複定義されていた。
より堅牢なlist/single scheduler対応版(926行目)を残し、古い定義を削除。
- gin_channels=256→512: FT時の滑舌・ノイズ劣化を解消
- --keep-emb-g: frozen emb_g保持方式 (言語別話者mean初期化)
- --dp-lr: Duration Predictor専用学習率 (differential LR)
- --no-freeze-dp: freeze-dp自動有効化のオーバーライド
- テスト追加: test_keep_emb_g.py, test_dp_lr.py
- CLAUDE.md: VITS2 FT品質検証完了状態を反映、gin256/512全実験結果
- docs/vits2-ft-experiments.md: 全VITS2実験ログ、gin_channels/PE balance matrix、A-E個別テスト計画
- __main__.py: gin_channels自動検出をベースcheckpointから継承に修正
@ayutaz
ayutaz force-pushed the feat/vits2-upgrade branch from 610befa to 97a74ea Compare April 4, 2026 02:51
- VITS1+MelPEのみ20ep学習→全帯域で深刻な品質劣化 (mid -25dB, hi -39dB)
- 80ch mel入力ではenc_qの潜在表現品質が不足しデコーダが高周波を学習不能
- VITS2固有機能の個別検証状況テーブルをCLAUDE.mdに追加
@ayutaz

ayutaz commented Apr 5, 2026

Copy link
Copy Markdown
Owner Author

VITS2 品質検証完了 — 全構成でVITS1以下、対応見送り

結論

VITS2の全5機能 (A-E) は、単体でも組み合わせでもVITS1の品質を超えられませんでした。 本issueは実験記録を添付してクローズします。

VITS2のコード実装自体は feat/vits2-upgrade ブランチに保持しますが、devへのマージは行いません。


実施した実験 (2026-03-20 ~ 2026-04-05)

FT実験 (つくよみちゃん 100発話)

# ベース gin_channels 主要設定 結果
gin256 v1 VITS2 60ep 256 freeze-dp duration 30-130%長い
gin256 v2 VITS2 60ep 256 DurDisc + no-freeze-dp 改善するも依然長い
gin256 v3 VITS2 60ep 256 warmup, cosine, keep-emb-g 外国人っぽいJA発音
gin256 v4 VITS2 60ep 256 JA話者mean + DurDisc ノイズ (speaker_cond_enc silent drop)
gin256 v5 VITS2 60ep 256 freeze-dp, speaker_cond_enc=True 周波数=VITS1同等、だが速度・声質で劣る
gin512 v1 VITS2 60ep 512 no-freeze-dp, dp-lr, DurDisc 機械音 + 遅い
gin512 v2 VITS2 60ep 512 freeze-dp, speaker_cond_enc 雑音 + 遅い (ベース品質問題)
gin512 v3 VITS2 200ep 512 FTなし (ベース評価) 水中感 (conditioning比率過剰)

ベースモデル構成変更実験

# Posterior Encoder gin VITS2機能 結果
B1 Linear Spec (513ch) 256 A+B+C+D hi-mid=-31.3dB, 全帯域劣悪
B2 Linear Spec (513ch) 512 A+B+C+D hi-mid=-86.0dB, rms=0.072

個別機能検証

# 構成 追加機能 結果
T-E VITS1 + E のみ Mel Posterior Encoder ❌ mid -25dB, hi -39dB

VITS2固有機能 (A-E) の最終評価

ID 機能 単体テスト 組合せテスト 最終判定
A Deterministic DP (SDP廃止) 未実施 B2で❌ 採用不可 (B2で証明)
B Duration Discriminator V2 未実施 B2で❌ 採用不可 (Aが必須、B2で証明)
C Speaker-Conditioned TextEncoder 未実施 B2で❌, v5で声質劣化 採用不可
D Noise-Scaled MAS 未実施 B2で❌ 採用不可 (B2で証明)
E Mel Posterior Encoder T-Eで❌ 全VITS2実験で❌ 採用不可 (単体で証明)

T1-T4 (A-D個別テスト) を実施しない理由

  1. B2実験で A+B+C+D の組合せが壊滅的 — VITS1ベース (gin512+linspec) でも全帯域で大幅劣化。個別にOKでも組合せが使えない
  2. gin256 v5 (最良VITS2) でもVITS1に勝てない — 周波数のみ同等で速度・声質が劣る
  3. 96 GPU時間 (4x V100 × 24h × 4テスト) の投資に対して判断が変わるシナリオがない

発見・修正したバグ (3件)

  1. TextEncoder cond_proj未実行 (models.py:218) — self.encoder(x, x_mask)g を渡していなかった
  2. gin_channels自動設定 (main.py) — 常に512に設定されていたのをベースcheckpointから継承に修正
  3. gin256 v4の誤診 — 「容量不足」ではなく speaker_conditioned_encoder=False による cond_layer/cond_proj silent drop

技術的知見

知見 詳細
gin_channels/PE バランス gin256↔mel(80ch), gin512↔linspec(513ch) がバランス。交差は失敗
Mel PE情報損失 80ch melではenc_qの潜在表現品質が不足し、デコーダが高周波を学習不能
conditioning比率 gin512のdec.cond/conv_pre比=6.16はVITS1の2.97の2倍。高周波欠損の根本原因
CosineAnnealingLR 後半LR≈0で有効学習ep数が不足。ExponentialLRの方がVITS1では優位
3-optimizer干渉 G+D+DurDiscの3-optimizer構成がgradient希薄化を引き起こす

今後の方針

@ayutaz ayutaz closed this Apr 5, 2026
ayutaz added a commit that referenced this pull request Apr 9, 2026
PR #240 で全5構成の実験を実施し、VITS2 は単体でも組み合わせでも
VITS1 の品質を超えられないことが確認済み。
Duration Discriminator (--vits2) 関連コードを全て除去。

除去対象: DurationDiscriminator クラス, 3-optimizer 構成,
--vits2/--dur-disc-lr/--lambda-dur CLI, test_vits2.py
ayutaz added a commit that referenced this pull request Apr 9, 2026
PR #240 で全5構成の実験を実施し、VITS2 は単体でも組み合わせでも
VITS1 の品質を超えられないことが確認済み。
Duration Discriminator (--vits2) 関連コードを全て除去。

除去対象: DurationDiscriminator クラス, 3-optimizer 構成,
--vits2/--dur-disc-lr/--lambda-dur CLI, test_vits2.py
ayutaz added a commit that referenced this pull request Apr 9, 2026
* docs: M1 (v1.12.0) チケット作成 — README刷新・HF整備・ベンチマーク・LLMガイド

M1 First Impression フェーズの12チケットを docs/tickets/M1/ に作成。
各チケットに目的・実装詳細・エージェントチーム構成・テスト計画・
懸念事項・設計振り返り・後続連絡事項の7セクションを記載。

* docs: M2a (v1.13.0) チケット作成 — Python高レベルAPI・CI最適化・DX改善

M2a コア開発+DX フェーズの9チケットを docs/tickets/M2/ に作成。
PiperPlusクラス設計、dorny/paths-filter CI最適化、CONTRIBUTING拡充など。

* docs: M2b (v1.14.0) チケット作成 — Wyoming・npm改善・認知度施策・Rust API

M2b エコシステム統合+認知度フェーズの12チケットを docs/tickets/M2/ に作成。
Wyoming Protocol、Show HN/Reddit、Rust SynthesisParams設計など。

* docs: M3a (v2.0.0) チケット作成 — Voice Cloning・VITS2・SSML・MOS

M3a 音質・コア機能フェーズの9チケット (8タスク+Go/No-Goゲート) を作成。
ZSE-VITS Speaker Encoder、VITS2 adversarial DP、研究バッファ含む。

* docs: M3b (v2.1.0) チケット作成 — モデルZoo・Unity UPM・Awesomeリスト

M3b エコシステム拡張フェーズの11チケットを作成。
LJSpeech/あみたろ/HiFi-TTS/SIWIS/KOモデル学習、Unity P/Invoke統合など。

* docs: チケットインデックス + マイルストーン相互紐づけ

- docs/tickets/README.md: 全53チケットのインデックス + 進捗サマリー + 依存関係図 + フェーズ横断設計振り返り
- milestones-2026-H1H2.md: 全タスク一覧にチケット詳細リンク列を追加
- v1.11.0-market-reaction-and-improvements-2026-04.md: ソースドキュメント追加

* fix: M1チケットレビュー指摘修正 + M1-13リリースチケット追加

Critical: M1-01 CLI例修正 (piper-tts-plusはCLI非対応)
Major: M1-03 library_name判断基準、M1-06 Optional/Required区別、
  M1-07 Windows psutil対応、M1-08 Piper/piper1-gpl混同修正、
  M1-09 LangChain例修正、M1-12 latestタグ条件修正
Minor: M1-02/05/10/11 改善
新規: M1-13 v1.12.0リリース作業チケット

* fix: M2aチケットレビュー指摘修正

Critical: M2-01 piper_train依存方向の明確化・パッケージツリー図追加
Major: M2-03 CI WF作成タイミング、M2-04 ORT pip競合解決、
  M2-05 required checks解決策・全WF分類・Cargoパス修正
Minor: M2-02 format制限、M2-06〜09 各種改善
橋渡し: M2-01にM3-1 Speaker Encoder連携情報追加

* fix: M2bチケットレビュー指摘修正

Critical: M2-19 Rust API設計を実コードと整合 (PiperVoice対象に再定義)
Major: M2-10 piper_train依存明確化・6言語限定
Minor: M2-11 docker-compose v2対応、M2-13〜18 各種改善、
  M2-20 SV文字修正、M2-21 PR#297補足

* fix: M3aチケットレビュー指摘修正

Major: M3-02 speaker_embedding_mask方式確定、M3-03 VC専用resume設計、
  M3-06 DiDiSpeech-2(SA)除外・WenetSpeech+AISHELL-3安全案
中: M3-01 ECAPA-TDNN次元確認、M3-04 メルONNX内包を本案に、
  M3-05 manual optimization調査、M3-07 pitch除外(v2.1.0延期)
GATE: Stage 2品質ゲート追加、F5-TTS工数修正(+45-60d)

* fix: M3bチケットレビュー指摘修正

Critical: M3-09〜12 --ljspeech-dir修正(存在しないオプション)、
  M3-15 P/Invoke宣言をC API実シグネチャと整合
Major: M3-13 emb_lang拡張PoC追加・KSS(NC)除外・CSS10第一候補
中: M3-10 ライセンスブロッカー化、M3-11 リサンプリング具体化、
  M3-15 バイナリ配布方式調査、M3-17 ORT調達・macOS明示
Minor: M3-14/16/18/19 各種改善

* docs: チケットインデックス更新 — M1-13追加、合計54チケット

* feat: M1チケット実装 — README改善、ベンチマーク、LLMガイド、Docker Hub対応

M1-01: README「30秒で試す」セクション追加 (日英)
M1-02: 「Try in Browser」WebAssemblyバッジ追加
M1-07: scripts/benchmark.py ベンチマークスクリプト作成
M1-08: README にベンチマーク比較表追加 (暫定値)
M1-09: docs/guides/llm-ecosystem.md LLMエコシステム統合ガイド
M1-10: docker/ollama-stack/ Ollama+piper-plus docker-compose
M1-12: docker-build.yml に v* タグでのDocker Hub公開を追加

* feat: M2チケット実装 — Python API、CI最適化、DX改善、npmドキュメント

M2-01: Python高レベルAPI (PiperPlus クラス) + AudioResult (M2-02統合)
M2-05: CI path filter導入 (dorny/paths-filter) + required pass-through jobs
M2-07: PRテンプレート拡充 (コンポーネントチェックリスト)
M2-08: CONTRIBUTING.md拡充 (テストコマンド、ライセンスポリシー、初PRガイド)
M2-13: npm README改善 (importmap、Kokoro.js比較表)
M2-14: WASM バンドラーガイド (Vite/webpack/Next.js)

* feat: M2チケット実装 — concurrency group、Wyoming、Rust API、SVテスト

M2-06: 14 PRワークフローに concurrency group 追加
M2-10: Wyoming Protocol TTS アダプタ (Home Assistant統合)
M2-19: Rust SynthesisParams + synthesize_with_params() API改善
M2-20: SV phonemizer 統合テスト 30件追加

* docs: M1-M2「一から作り直すなら」エージェントチーム議論レポート

4チーム (API設計/コード品質/市場戦略/アーキテクチャ) による
独立分析の結果を統合。主要発見:
- 推論ロジック4箇所重複 → piper_plus.engine 共通化
- Wyoming が PiperPlus 未使用 + 同期ブロッキング
- README 英語デフォルト化が国際認知度のボトルネック
- HACS アドオンが最大の採用機会

* refactor: レトロスペクティブ指摘の全問題点を修正

アーキテクチャ (CRITICAL):
- piper_plus.engine モジュール新設 — piper_train 非依存の推論エンジン
- api.py を engine ベースに書き換え (piper_train import を排除)
- Wyoming アダプタを PiperPlus 使用の薄いラッパーに書き換え (240→71行)
- Wyoming に asyncio.to_thread() 追加 (イベントループブロッキング解消)

コード品質 (HIGH):
- api.py: 空テキストバリデーション、パラメータ範囲チェック追加
- _model_resolver.py: アトミックDL (tmpdir→rename)、エラーメッセージ改善
- audio.py: 空音声ガード追加
- benchmark.py: --threads 引数追加

CI簡素化 (MEDIUM):
- 7つの -required ジョブを1つの ci-required に統合
- CI config トリガーを言語別に細分化 (不要なジョブ実行を削減)

ドキュメント (MEDIUM):
- README「30秒で試す」に PiperPlus API を反映
- ベンチマーク表の「暫定値」表記を改善
- Piper archived メッセージを強化
- Quick Start 重複に相互リンク追加
- llm-ecosystem.md の「準備中」を修正
- モデル解決仕様書 + テストベクトル作成

* feat: M3チケット実装 — VITS2、Voice Cloning、SSML、Unity UPM、MOS ベンチマーク

M3a (v2.0.0) 音質・コア機能:
- M3-01: Speaker Encoder (ECAPA-TDNN) モジュール実装
- M3-02: SynthesizerTrn speaker_embedding 入力パス追加
- M3-04: 全5ランタイム (Rust/C#/Go/WASM/C++) Voice Cloning 統合
- M3-05: VITS2 adversarial Duration Predictor アップグレード
- M3-07: SSML 基本サポート (speak, break, prosody rate)
- M3-08: MOS ベンチマークツール群

M3b (v2.1.0) エコシステム拡張:
- M3-14: モデル投稿ガイド + Issue テンプレート
- M3-15: Unity UPM パッケージ (P/Invoke + AudioClip)
- M3-16: Unity サンプルシーン 5種 + 統合ドキュメント
- M3-17: iOS/Android ビルド CI (toolchain + workflow)

* fix: レトロスペクティブ全問題修正 + TDD品質改善

P0 修正:
- API層テスト追加: api.py/engine.py/model_resolver.py/audio.py (133テスト)
- SSML 3ランタイム実装: Rust (39テスト), C# (59テスト), Go (67テスト)
- Speaker Encoder クロスランタイムテスト + Golden file (C# 23, Go 26, Rust 16)

P1 修正:
- メルフィルタバンク edge case 修正 (Rust/C#/Go/JS 4ランタイム)
- VITS2 dur_disc_lr デフォルト 2e-4→1e-4, lambda_dur 1.0→0.5
- speaker_embedding mask 型修正 (>0.5 → >=1), ONNX dummy入力 ones化
- spk_proj 次元不一致時の再生成修正
- Python CLI --reference-audio 統一 (--encode-speaker は後方互換で維持)
- Wyoming handler テスト追加 (11テスト)

P2 改善:
- test_ssml.py parametrize化 (61→36関数, カバレッジ維持)
- 共有conftest.py (make_vits_model/make_synthesizer_trn)
- テスト名を振る舞い記述に改善 (t-wada TDD原則)
- ORT バージョン一元管理 + ort-versions.md
- ベンチマークツールテスト (30テスト)

* feat: Wyoming Docker + Home Assistant 統合ガイド

M2-11: Wyoming Dockerfile (multi-stage build) + docker-compose + .env.example
M2-12: Home Assistant 統合ガイド + Wyoming Protocol 統合テスト (27テスト)

* docs: チケット進捗・CLAUDE.md・マイルストーン一括更新

- tickets/README.md: 31/54チケット完了に進捗表更新
- CLAUDE.md: M3実装済み10機能追加 (+150行)
- milestones-2026-H1H2.md: DoD 15項目チェック済み更新
- retrospective: M3振り返りセクション追記

* chore: 完了済み31チケット削除、残り23件(外部作業)のみ保持

削除: M1 7件, M2 14件, M3 10件 (全てコード実装完了済み)
残存: M1 6件, M2 7件, M3 10件 (HF/GPU/記事/SNS等の外部作業)
tickets/README.md を残りチケットのみに更新

* chore: 外部作業チケット23件削除、README をサマリーのみに簡素化

全チケットファイル (.md) を削除し、M1/M2/M3 ディレクトリを除去。
README.md はリンクなしの残タスク一覧に書き換え。

* chore: docs/tickets/ ディレクトリ削除

* chore: 役割を終えた計画文書2件を削除

* chore: 不要な内部文書3件 + 空ディレクトリ削除

- retrospective-m1-m2-from-scratch.md (知見はCLAUDE.mdに反映済み)
- benchmark-mos.md (ツールは tools/benchmark/ に存在)
- ecosystem-investigation-2026-04.md (時系列調査、役割終了)
- releases/ (空ディレクトリ)

* fix: 6ランタイムのテスト327件を修正 (全テスト ALL GREEN)

- Rust: ort::inputs! 戻り値型修正、SynthesisParams ..Default::default() 追加、golden fixture パス修正
- Python: 冗長 legacy テスト12件削除 (新G2Pテストでカバー済み)
- Python: test_custom_dict/test_phonemizer_registry を実APIに修正
- Python runtime: gradio遅延インポート、mock パス修正、config kwarg修正
- Go: French phonemizer i++ 漏れ修正、PT/SV golden test に PUA チェック追加

* ci: 4つのテストカバレッジGAPを修正

- python-tests.yml: test/ (58テスト), tools/benchmark/ (30テスト) 追加
- python-tests.yml: runtime テスト全件 (config, training, CLI等) 追加
- test-webassembly.yml: 欠落していた13テストファイル (optimization, edge-cases等) 追加
- pytest.ini: testpaths に test/ と tools/benchmark 追加

* fix: PR #331 Copilot レビュー指摘16件を修正

- VITS2 dur_info を SDP パスでも計算 (models.py)
- Generator step で dur_disc の requires_grad 切替 (lightning.py)
- ONNX export speaker_embedding axis 1 を fixed 256 に変更
- C# PiperSession/SessionFactory: 未指定時もゼロテンソル提供 + mask 2D化
- Go engine: mask 形状 (1) → (1,1) に修正
- Unity: PCM除数 32767→32768, Editor preview を update callback に変更
- C API: _reserved[5] で ABI サイズ維持, Speaker Encoder を experimental 明記
- SSML: 100KB サイズ制限追加
- CI gate: cancelled も失敗扱いに変更

* fix: Rust unused_mut warning を修正 (speaker_encoder.rs)

* revert: VITS2 Duration Discriminator を除去 (PR #240 で検証済み・却下)

PR #240 で全5構成の実験を実施し、VITS2 は単体でも組み合わせでも
VITS1 の品質を超えられないことが確認済み。
Duration Discriminator (--vits2) 関連コードを全て除去。

除去対象: DurationDiscriminator クラス, 3-optimizer 構成,
--vits2/--dur-disc-lr/--lambda-dur CLI, test_vits2.py

* ci: 全CI失敗を修正 (ruff, clippy, rustfmt, dotnet format, テスト)

- Python: ruff auto-fix (import順序, deprecated typing, 未使用import)
- Rust: clippy修正 (redundant_closure, needless_range_loop, map_or, manual_flatten, approx_constant 等) + rustfmt
- C#: dotnet format (SsmlParser.cs インデント)
- C++: test_c_api.cpp _reserved配列ループ範囲を sizeof で算出
- Go CI: sparse-checkout に test/fixtures 追加
- WASM: 削除済みファイル参照テスト除去, baseline更新
- Python tests: espeak-ng/huggingface-hub 未インストール時 skip

* ci: 残りのlint失敗を修正 (ruff残5件, ruff format, Go lint)

- ruff: F841 (未使用変数labels), PLC0415 (noqa), E741 (変数名l→lang)
- ruff format: 20ファイルのフォーマット統一
- Go lint: if-else→switch (gocritic), gofmt, unused const 除去
@ayutaz
ayutaz deleted the feat/vits2-upgrade branch May 12, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants