0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Raspberry PiにVOICEVOX CORE を実装する手順

Last updated at Posted at 2025-08-03

Raspberry Pi で VOICEVOX CORE を構築する手順

使用するバージョン
Raspberry Pi5 16GB
microSDカード 128GB

Raspberry Pi でVOICEVOXを使用するには2つ方法があるみたいです

  • Dockerで起動する
  • VOICEVOX CORE をインストールする

最初は VOICEVOX CORE から手順を説明

✅ 必要パッケージのインストール

sudo apt update
sudo apt install -y python3-pip virtualenv git cmake libgomp1 libsndfile1 libatlas-base-dev

✅ 仮想環境の作成と有効化

cd ~
python3 -m venv venv
source ~/venv/bin/activate

✅ VOICEVOX CORE のホイールをインストール

cd ~/voicevox_core_runtime
wget https://github.com/VOICEVOX/voicevox_core/releases/download/0.14.4/voicevox_core-0.14.4+cpu-cp38-abi3-linux_aarch64.whl
pip install voicevox_core-0.14.4+cpu-cp38-abi3-linux_aarch64.whl

✅ onnxruntime のライブラリ設定

export LD_LIBRARY_PATH=~/voicevox_core_runtime/onnxruntime-linux-aarch64-1.13.1/lib:$LD_LIBRARY_PATH

.bashrc に追記すると永続化可能


✅ OpenJTalk 辞書の取得と展開

cd ~/voicevox_core_runtime
wget https://jaist.dl.sourceforge.net/project/open-jtalk/Dictionary/open_jtalk_dic-1.11/open_jtalk_dic_utf_8-1.11.tar.gz
tar xzvf open_jtalk_dic_utf_8-1.11.tar.gz

✅ テスト用 Python スクリプト

voicebox_utils.py

from voicevox_core import VoicevoxCore
import wave
import os

OPEN_JTALK_PATH = os.path.expanduser("~/voicevox_core_runtime/open_jtalk_dic_utf_8-1.11")
core = VoicevoxCore(open_jtalk_dict_dir=OPEN_JTALK_PATH)

def create_wav(text: str, output_path: str = "output.wav", speaker_id: int = 1):
    if not core.is_model_loaded(speaker_id):
        core.load_model(speaker_id)
    audio_query = core.audio_query(text, speaker_id)
    wav = core.synthesis(audio_query, speaker_id)
    with wave.open(output_path, "wb") as wf:
        wf.setnchannels(1)
        wf.setsampwidth(2)
        wf.setframerate(24000)
        wf.writeframes(wav)
    print(f"✅ 保存完了: {output_path}")

test_voice.py

from voicebox_utils import create_wav

create_wav("こんにちは、テスト音声です", "output.wav")

✅ 再生確認

aplay output.wav

🔁 よくあるエラーと対策

エラー内容 対策
libonnxruntime.so.1.13.1 が見つからない LD_LIBRARY_PATH を設定
OpenJTalkの辞書が読み込まれていません open_jtalk_dict_dir を正しく指定
AttributeError: synthesize synthesis が正しい関数名

VOICEVOX Core 実行時のエラーと解決方法

❌ エラー内容

ImportError: libonnxruntime.so.1.13.1: cannot open shared object file: No such file or directory

📌 原因

VOICEVOX Core の実行に必要な libonnxruntime.so.1.13.1 という共有ライブラリがシステムの共有ライブラリ検索パスに含まれていないためです。

✅ 解決方法

方法1: 毎回手動で環境変数を設定

export LD_LIBRARY_PATH=$HOME/voicevox_core_runtime/onnxruntime-linux-aarch64-1.13.1/lib:$LD_LIBRARY_PATH

方法2: .bashrc に追記して恒久的に設定

echo 'export LD_LIBRARY_PATH=$HOME/voicevox_core_runtime/onnxruntime-linux-aarch64-1.13.1/lib:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc

方法3: 仮想環境ごとに設定

仮想環境を使っている場合は、以下のファイルの末尾に追記:

~/venv/bin/activate
export LD_LIBRARY_PATH=$HOME/voicevox_core_runtime/onnxruntime-linux-aarch64-1.13.1/lib:$LD_LIBRARY_PATH

🧪 確認方法

python3 -c "from voicevox_core import VoicevoxCore; print('✅ 読み込み成功')"

📝 備考

  • 仮想環境内では .bashrc の内容は自動で読み込まれません。
  • ライブラリパスを正しく設定しないと ImportError が発生します。

おまけ

パーテイションの容量が足りない場合

インストールコマンド

sudo apt install gparted

本体で以下のコマンド
※GUIでの操作が必要なのでRasberry Pi で実行してください

sudo gparted

Dockerで使用する方法

sudo apt update
sudo apt install -y docker.io

sudo usermod -aG docker ${USER}

docker pull voicevox/voicevox_engine:latest

docker run -d -p 50021:50021 voicevox/voicevox_engine:latest

curl -X POST -d '{"text":"こんにちは、これは音声合成のテストです。"}' 
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?