feat: マルチ言語モデルの実装 (#23)#96
Closed
ayutaz wants to merge 9 commits into
Closed
Conversation
ayutaz
added a commit
that referenced
this pull request
Jul 19, 2025
- Added current implementation status of piper-plus - Noted that Japanese phoneme issues (#787) are already resolved - Listed existing PRs (#96-#100) for TTS improvements - Updated priorities based on what's already implemented - Focused recommendations on features not yet in piper-plus: * Raw Phoneme Input (PR #742) * IPA phonemes support (PR #401) * GPU device designation (PR #429) * Silence randomness control (Issue #817) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6 tasks
日本語(OpenJTalk)と他言語(espeak-ng)を統合したマルチ言語TTSモデルを実装 Phase 1 - 基礎実装: - 統一音素IDマップ(132音素)の実装 - マルチ言語音素化器(言語自動検出・分割) - データセットフォーマッター(言語タグ埋め込み型) - preprocess.pyへの統合(--multilingualフラグ) Phase 2 - モデル実装: - VITSモデルへの言語埋め込み層追加(64次元) - PyTorch Lightning対応の学習スクリプト - マルチ言語データセットクラス - 単一言語モデルからの転移学習サポート 対応言語: - 日本語(OpenJTalk) - 英語、中国語、スペイン語、フランス語、ドイツ語、韓国語(espeak-ng) - コードスイッチング(文内言語切り替え)対応 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
実際のデータセットを使用したマルチ言語モデル学習のための完全な前処理パイプラインを実装 機能追加: - 複数言語データセットの自動統合処理 - 話者ID管理と言語メタデータ付与 - 並列前処理とキャッシュ機能 - 使いやすいシェルスクリプトインターフェース ツール・スクリプト: - preprocess_multilingual_dataset.py: メイン前処理スクリプト - run_multilingual_preprocessing.sh: 実行用シェルスクリプト - verify_multilingual_setup.py: セットアップ検証ツール ドキュメント: - multilingual-dataset-preparation-guide.md: 詳細な準備ガイド - README_multilingual.md: クイックスタートガイド - 設定ファイル例とデータセット構造定義 これにより、LJSpeech形式の言語別データセットから統一されたマルチ言語データセットを作成し、学習可能な状態まで前処理できるようになりました。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
piper_phonemizeが利用できない環境でも動作するよう改善 改善内容: - multilingual_stub.py: 依存関係がない環境用のスタブ実装 - 日本語のみサポート(OpenJTalk使用) - 他言語は簡易的な文字ベース音素化 - 適切な警告メッセージ表示 - preprocess.py: インポート時のフォールバック処理 - フル実装が失敗した場合はスタブを使用 - 後方互換性を維持 - infer_multilingual.py: 推論スクリプト - 学習済みモデルからの音声合成 - 多言語対応(日本語、英語、中国語等) - WAVファイル出力機能 これにより、最小限の依存関係(pyopenjtalk)で日本語TTSが動作し、 完全な環境では全言語対応が可能になりました。 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Remove unused imports in multilingual.py and preprocess.py - Fix whitespace issues in blank lines - Update deprecated type annotations (List -> list) - Add missing newlines at end of files - Use set comprehension instead of generator - Add noqa comment for global statement warning - Comment out unused variables (mel, y) in lightning_multilingual.py 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing main() calls to __main__ blocks - Fix blank lines with whitespace - Remove unused variable assignment (output_path) - Use importlib.util.find_spec for import availability checks - Add noqa comments for intentional imports in conditional blocks - Fix subprocess.run check parameter warning All ruff checks now pass successfully 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Formatting changes to comply with ruff formatter requirements: - Consistent indentation and line breaks - Proper spacing around operators and in dictionaries - Function parameter formatting - Import statement formatting No functional changes, only code style improvements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
ayutaz
force-pushed
the
feature/multi-language-investigation
branch
from
July 24, 2025 12:16
4254e11 to
bc5b00b
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR implements a comprehensive multilingual TTS (Text-to-Speech) model that unifies Japanese (OpenJTalk) and other languages (espeak-ng) into a single model. The implementation enables single-model synthesis for multiple languages with code-switching support.
- Unified phoneme ID mapping system managing 132 phonemes across languages
- Multilingual phonemizer with automatic language detection and appropriate phonemization engine selection
- Complete model architecture with language embeddings and PyTorch Lightning integration
Reviewed Changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/test_phoneme_map_only.py | Unit test for phoneme mapping functionality without external dependencies |
| test/test_multilingual_simple.py | Simple integration test for multilingual phonemizer components |
| test/test_multilingual_phonemizer.py | Comprehensive unit tests for multilingual phonemization system |
| src/python/piper_train/vits/models_multilingual.py | Multilingual VITS model with language embedding support |
| src/python/piper_train/vits/lightning_multilingual.py | PyTorch Lightning module for multilingual VITS training |
| src/python/piper_train/vits/dataset_multilingual.py | Dataset implementation for multilingual training data |
| src/python/piper_train/train_multilingual.py | Training script for multilingual VITS models |
| src/python/piper_train/preprocess.py | Extended preprocessing with multilingual support |
| src/python/piper_train/phonemize/multilingual_stub.py | Fallback implementation when piper_phonemize is unavailable |
| src/python/piper_train/phonemize/multilingual_phoneme_map.py | Unified phoneme ID mapping for multilingual TTS |
| src/python/piper_train/phonemize/multilingual_dataset.py | Dataset formatter for multilingual TTS training |
| src/python/piper_train/phonemize/multilingual.py | Core multilingual phonemizer combining OpenJTalk and espeak-ng |
| scripts/verify_multilingual_setup.py | Setup verification and functionality testing script |
| scripts/run_multilingual_preprocessing.sh | Shell script for multilingual dataset preprocessing |
| scripts/preprocess_multilingual_dataset.py | Python script for preprocessing multilingual datasets |
| scripts/prepare_multilingual_dataset.py | Script for creating sample multilingual datasets |
| scripts/infer_multilingual.py | Inference script for multilingual VITS models |
| examples/multilingual_dataset_example.json | Example configuration for multilingual datasets |
| docs/multilingual-phase2-summary.md | Implementation summary for Phase 2 |
| docs/multilingual-model-specification.md | Technical specification for multilingual model design |
| docs/multilingual-investigation.md | Investigation report for multilingual implementation |
| docs/multilingual-implementation-summary.md | Overall implementation summary |
Comments suppressed due to low confidence (1)
src/python/piper_train/vits/models_multilingual.py:13
- Remove the unnecessary pass statement and comment. This line serves no purpose and adds clutter to the code.
DurationPredictor,
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- importブロックの並び順を修正 - 動的importにnoqaコメントを追加 - dict.fromkeys()の使用に変更
- prepare_multilingual_dataset.pyのフォーマット修正 - multilingual_dataset.pyのフォーマット修正
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.
概要
日本語(OpenJTalk)と他言語(espeak-ng)を統合したマルチ言語TTSモデルを実装しました。単一のモデルで複数言語の音声合成が可能になります。
関連Issue
Closes #23
実装内容
Phase 1 - 基礎実装
--multilingualフラグでの有効化Phase 2 - モデル実装
Phase 3 - 実用化
対応言語
使用方法
1. セットアップ確認
2. データセット準備
3. モデル学習
4. 推論
python scripts/infer_multilingual.py \ --checkpoint model.ckpt \ --text "こんにちは、Hello world\!" \ --language ja \ --output output.wav主な追加ファイル
音素化システム:
src/python/piper_train/phonemize/multilingual.pysrc/python/piper_train/phonemize/multilingual_phoneme_map.pysrc/python/piper_train/phonemize/multilingual_stub.pyモデル実装:
src/python/piper_train/vits/models_multilingual.pysrc/python/piper_train/vits/lightning_multilingual.pysrc/python/piper_train/train_multilingual.pyツール・スクリプト:
scripts/preprocess_multilingual_dataset.pyscripts/run_multilingual_preprocessing.shscripts/infer_multilingual.pyドキュメント:
README_multilingual.mddocs/multilingual-dataset-preparation-guide.mddocs/multilingual-model-specification.mdテスト
技術的詳細
音素IDマッピング
言語埋め込み
依存関係
pyopenjtalk(日本語のみ)pyopenjtalk+piper-phonemize(全言語)今後の改善案
レビューお願いします
このPRは大規模な変更を含みますが、既存の機能には影響しません。マルチ言語機能は
--multilingualフラグで明示的に有効化する必要があります。🤖 Generated with Claude Code