初めに
高速推論が可能なZero ShotTTSを触ってみます
処理のフローとしては以下のようになっています
テキスト → トークナイザ → Text Encoder → FM Decoder → Vocoder → 波形(24kHz)
開発環境
- Windows 11
- uv 0.9.x
- cuda 13.0
環境構築
uvを使って構築するため、以下の pyproject.tomlを作成します
[project] name = "zipvoice" version = "0.1.0" description = "Fast and High-Quality Zero-Shot Text-to-Speech with Flow Matching" readme = "README.md" requires-python = ">=3.10,<3.13" dependencies = [ "cn2an>=0.5.23", "huggingface-hub>=1.2.3", "inflect>=7.5.0", "jieba>=0.42.1", "lhotse>=1.32.1", "numpy>=1.26.0", "pydub>=0.25.1", "pypinyin>=0.55.0", "safetensors>=0.7.0", "tensorboard>=2.20.0", "torch>=2.0.0", "torchaudio>=2.0.0", "vocos>=0.1.0", ] # Note: piper-phonemize must be installed separately: # uv pip install piper-phonemize --find-links https://k2-fsa.github.io/icefall/piper_phonemize.html [[tool.uv.index]] name = "pytorch-cu124" url = "https://download.pytorch.org/whl/cu124" explicit = true [tool.uv.sources] torch = { index = "pytorch-cu124" } torchaudio = { index = "pytorch-cu124" } [tool.uv] find-links = ["https://k2-fsa.github.io/icefall/piper_phonemize.html"] [tool.isort] profile = "black" [tool.black] line-length = 88
次に依存ライブラリをインストールします
uv sync uv pip install piper-phonemize --find-links https://k2-fsa.github.io/icefall/piper_phonemize.html uv pip install -r requirements_eval.txt
実行
単一文の場合は以下で推論を行います
uv run python -m zipvoice.bin.infer_zipvoice \ --model-name zipvoice \ --prompt-wav prompt.wav \ --prompt-text "プロンプト音声の書き起こし" \ --text "合成するテキスト" \ --res-wav-path result.wav
以下がRTX 4070 ti superを用いたときの測度計測結果です。中国語の場合時間がかかっているのは、中国語のピンイン変換が原因みたいなので、トークンに対しての測度は同じでした
| 言語 | 推論時間 | 生成音声長 | RTF | 速度 | |--------|----------|------------|-------|--------------------| | 英語 | 1.25秒 | 6.73秒 | 0.186 | 5.37x リアルタイム | | 中国語 | 1.66秒 | 2.74秒 | 0.606 | 1.65x リアルタイム |