Skip to content

05. VOICEVOX エンジン (headless) を macOS に入れる

Donack のボイス担当「満別花丸」を呼び出すための音声合成エンジン。 GUI アプリ版もあるが、サーバー用途では エンジン単体 (headless) が軽い。

仕様

項目
エンジンVOICEVOX 0.25.2 (2026-05 時点)
APIHTTP / http://127.0.0.1:50021
ボイス満別花丸 ノーマル (speaker_id=69)
出力WAV (24kHz / 16bit / mono)
ライセンス各キャラクター別の利用規約あり (公式 で確認)

インストール

bash
brew install sevenzip
mkdir -p ~/Library/Application\ Support/voicevox-engine
cd ~/Library/Application\ Support/voicevox-engine

# 約 1.7GB のダウンロード
curl -L "https://github.com/VOICEVOX/voicevox_engine/releases/download/0.25.2/voicevox_engine-macos-arm64-0.25.2.7z.001" -o engine.7z.001

# 解凍
7zz x engine.7z.001 -y
ls macos-arm64/   # → engine_internal / libvoicevox_core.dylib / model / resources / run

起動

bash
nohup ~/Library/Application\ Support/voicevox-engine/macos-arm64/run \
  --host 127.0.0.1 --port 50021 \
  > /tmp/voicevox.log 2>&1 &
disown

初回起動はモデルロードで 5-10 秒。uvicorn のログが出れば OK。

bash
tail -f /tmp/voicevox.log
# INFO:     Uvicorn running on http://127.0.0.1:50021

動作確認

bash
# 満別花丸を検索
curl -s http://127.0.0.1:50021/speakers \
  | python3 -c "import json,sys; d=json.load(sys.stdin); print([{s['name']: [st for st in s['styles']]} for s in d if '満別' in s['name']])"

出力例 (スタイル別 ID):

IDスタイル
69ノーマル ← デフォルト推奨
70元気
71ささやき
72ぶりっ子
73ボーイ

API の基本フロー

合成は 2 段階の HTTP POST:

python
import urllib.request, urllib.parse, json

text = "こんにちは、ぼくはドナック"
speaker = 69

# 1) audio_query (アクセント情報 JSON を取得)
req = urllib.request.Request(
    f"http://127.0.0.1:50021/audio_query?speaker={speaker}&text=" + urllib.parse.quote(text),
    method="POST",
)
query = urllib.request.urlopen(req).read()

# 2) synthesis (WAV を取得)
req2 = urllib.request.Request(
    f"http://127.0.0.1:50021/synthesis?speaker={speaker}",
    data=query, method="POST",
    headers={"Content-Type": "application/json"},
)
wav = urllib.request.urlopen(req2).read()

open("/tmp/out.wav", "wb").write(wav)

自動起動 (launchd)

毎回手動起動が面倒なら ~/Library/LaunchAgents/com.voicevox.engine.plist を置く:

xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key><string>com.voicevox.engine</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/USERNAME/Library/Application Support/voicevox-engine/macos-arm64/run</string>
    <string>--host</string><string>127.0.0.1</string>
    <string>--port</string><string>50021</string>
  </array>
  <key>RunAtLoad</key><true/>
  <key>KeepAlive</key><true/>
  <key>StandardOutPath</key><string>/tmp/voicevox.out</string>
  <key>StandardErrorPath</key><string>/tmp/voicevox.err</string>
</dict>
</plist>
bash
launchctl load ~/Library/LaunchAgents/com.voicevox.engine.plist

bridge との連携

mac-studio/bridge/src/tts/voicevox.tsVoicevoxClient クラスが audio_query → synthesis → WAV ヘッダ除去 → 生 PCM までやる。 bridge は Claude 応答テキストを受け取って自動で VOICEVOX に流す。

トラブル

症状対処
起動時の DB 構築で長く待たされる初回のみ user.dict_csv 作成のため。2 回目以降は即起動
port 50021 が listen にならない別プロセスが掴んでいるかも。lsof -nP -iTCP:50021 で確認
合成が遅いCPU 版なのでテキストが長いと数秒。短文に区切ると体感速い
7z 展開で失敗sevenzip ではなく古い p7zip-full を使うと一部のフォーマットでエラー。brew install sevenzip 推奨

関連

aieo-product / stack-chan project