ホーム 暮らし Trying out Style-Bert-VITS2 on Mac

Trying out Style-Bert-VITS2 on Mac

藤崎 健人 藤崎 健人 • 更新: • 公開: • 読了約 13 分
目次

Hello. This is Shia.
This time, I tried out Style-Bert-VITS2, which allows for Japanese text-to-speech synthesis.

Verification Environment

ndcea94dd0ce0

I performed the verification on a Mac Studio (2025) with the following specs.

  • Apple M3 Ultra chip with 32-core CPU, 80-core GPU, and 32-core Neural Engine

  • 512GB unified memory

Installation

# ダウンロード
% git clone https://github.com/litagin02/Style-Bert-VITS2
% cd Style-Bert-VITS2/
バージョン
% git rev-parse HEAD
1d7a7a0d484d56eebe99c5fd88a9ba52091b87bd
% uv venv --python=3.11
% source .venv/bin/activate
% uv pip install -r requirements.txt
モデルのダウンロード
% python initialize.py

Speech Synthesis

A web frontend called the "Style-Bert-VITS2 Editor" is provided for performing speech synthesis, making it easy to test.

# Style-Bert-VITIS2 エディターを起動する
http://localhost:8000/ からアクセスできる
% python server_editor.py --inbrowser

You can generate speech simply by entering the text you want to be spoken into the text box and pressing the speech synthesis button.

However, if the text is long, it puts a significant load on the CPU.

You can offload processing to the GPU by using PyTorch's MPS backend, but due to compatibility issues, the output audio ends up sounding raspy.

% python server_editor.py --inbrowser --device mps

For example, you should be able to confirm this by generating audio for the following sentence from the JVS Corpus using both MPS and CPU.

  • VOICEACTRESS100_001: Also, like To-ji Temple, it is often placed in the center of the main Myoo, which are called the Five Great Myoo.

The audio data generated with MPS sounds raspy in the area marked with the red frame.

I have placed the data used for verification below.
This data was generated using the Style-Bert-VITS2 model: Koharu Ami, Amitaro's Voice Material Workshop (https://amitaro.net/).

(Update)
After investigating various things, I found a way to fix it.

In the requirements.txt for Style-Bert-VITS2, the versions of the following packages are specified.

torch<2.4
torchaudio<2.4

However, it seems there is a bug in this version of MPS, and updating it resolved the crackling issue.
At the very least, speech synthesis appears to be working without issues, though there is a possibility that some problems may arise.

% pip install -U torchaudio
% pip show torchaudio
Name: torchaudio
Version: 2.6.0
Summary: An audio package for PyTorch
Home-page: https://github.com/pytorch/audio
Author: Soumith Chintala, David Pollack, Sean Naren, Peter Goldsborough, Moto Hira, Caroline Chen, Jeff Hwang, Zhaoheng Ni, Xiaohui Zhang
Author-email: soumith@pytorch.org
License: 
Location: /Users/user/work/Style-Bert-VITS2/.venv/lib/python3.11/site-packages
Requires: torch
Required-by: pyannote.audio, speechbrain, stable-ts, torch-audiomentations, torch_pitch_shift
% pip show torch
Name: torch
Version: 2.6.0
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages@pytorch.org
License: BSD-3-Clause
Location: /Users/user/work/Style-Bert-VITS2/.venv/lib/python3.11/site-packages
Requires: filelock, fsspec, jinja2, networkx, sympy, typing-extensions
Required-by: asteroid-filterbanks, julius, lightning, openai-whisper, punctuators, pyannote.audio, pytorch-lightning, pytorch-metric-learning, speechbrain, stable-ts, torch-audiomentations, torch_pitch_shift, torchaudio, torchmetrics

The corrected data has been placed below.
This data was generated using the Style-BertVITS2 model: Koharu Ami, Amitaro's Voice Material Workshop (https://amitaro.net/) .

Script

I've decided to share the script I used for verification.
Please place it directly under the Style-Bert-VITS2 folder to use it.
Some parameters are fixed, but please feel free to modify it as needed.

The following is an example of how to use it.

# 再生
% python cli.py --device mps --text "また、東寺のように、五大明王と呼ばれる、主要な明王の中央に配されることも多い。" --play
test.wavに出力
% python cli.py --device mps --text "また、東寺のように、五大明王と呼ばれる、主要な明王の中央に配されることも多い。" --output-path test.wav
test.txtを読み込んで再生
% python cli.py --device mps --text-path test.txt --play

Benchmark

Since it now works properly on MPS, I measured the time taken for speech synthesis by inputting text that recites Jugemu 10 times.

% cat jugemu.txt 
寿限無、寿限無、五劫のすりきれ、海砂利水魚の、水行末・雲来末・風来末、食う寝るところに住むところ、やぶらこうじのぶらこうじ、パイポ・パイポ・パイポのシューリンガン、シューリンガンのグーリンダイ、グーリンダイのポンポコピーのポンポコナの、長久命の長助
...
CPU

It is slow.

% python cli.py --device cpu --text-path jugemu.txt
...
00-00 00:00:00 |  INFO  | cli.py:206 | load time = 1.28s
00-00 00:00:00 |  INFO  | cli.py:207 | preprocess time = 0.04s
00-00 00:00:00 |  INFO  | cli.py:208 | synthesis time = 108.56s
00-00 00:00:00 |  INFO  | cli.py:209 | total time = 109.88s
...
GPU

It is overwhelmingly faster than the CPU.

% python cli.py --device mps --text-path jugemu.txt
00-00 00:00:00 |  INFO  | cli.py:206 | load time = 1.27s
00-00 00:00:00 |  INFO  | cli.py:207 | preprocess time = 0.04s
00-00 00:00:00 |  INFO  | cli.py:208 | synthesis time = 7.63s
00-00 00:00:00 |  INFO  | cli.py:209 | total time = 8.94s

同じカテゴリの記事

藤崎 健人

芸能取材歴10年のデスク。所属事務所の公式リリース、番組公式サイト、配信サービスの告知を一次情報として採用し、裏付けの取れない内容は記事にしていません。

おすすめの関連記事