Contents

Install VoiceVox on Raspberry Pi

For enabling text to speech on Raspberry Pi, I setup Voicevox on Raspberry Pi4. I followed instruction on github|voicevox_core.

Install Voicevox-core downloader

As my Rpi 4 is on aarch64(the 64-bit extension of the ARM architecture family), I installed the latest binary with arm64 (voicevox_core-linux-arm64-cpu-0.14.4.zip).

1
2
% arch
aarch64

Install Voicevox-core downloader.

1
2
3
4
binary=download-linux-arm64
curl -sSfL https://github.com/VOICEVOX/voicevox_core/releases/latest/download/${binary} -o download
chmod +x download 
./download 

Output of ./download is like:

1
2
3
4
5
6
 INFO 対象OS: linux
 INFO 対象CPUアーキテクチャ: arm64
 INFO ダウンロードデバイスタイプ: cpu
 INFO ダウンロードvoicevox_coreバージョン: 0.14.4
voicevox_core-linux-arm64-cpu-0.14.4.zip                  Done!
open_jtalk_dic_utf_8-1.11.tar.gz                          Done!                                                                                                        INFO 全ての必要なファイルダウンロードが完了しました

Use sample code on python

Install pyenv on Raspberry Pi

As the python build is using cp38, I installed python 3.8.16 on pyenv on Raspberry Pi.

Install necessary information:

1
sudo apt install -y git openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev

Clone pyenv from git repository.

1
git clone https://github.com/yyuu/pyenv.git ~/.pyenv

Add below at ~/.bash_profile

1
2
3
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Check pyenv version

1
2
% pyenv -V
pyenv 2.3.19-4-g687944d9

Install python 3.8.17 on pyenv

Trying to install python 3.8.17 by pyenv install 3.8.17, I encountered ModuleNotfoundError _ctypes with missing libffi and _lzma with missing _lzma.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
Installing Python-3.8.17...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/tato/.pyenv/versions/3.8.17/lib/python3.8/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
WARNING: The Python ctypes extension was not compiled. Missing the libffi lib?
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/tato/.pyenv/versions/3.8.17/lib/python3.8/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'
WARNING: The Python lzma extension was not compiled. Missing the lzma lib?
Installed Python-3.8.17 to /home/tato/.pyenv/versions/3.8.17

For resolving this, I needed to install libraries by:

1
2
sudo apt install -y libffi-dev
sudo apt install -y liblzma-dev

Then I can run pyenv install 3.8.17 successfully.

Install wheel for voicevox_core

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

Setup environment using a downloader.

1
./download -o ./example/python

At ./example/python, create run.py with copying the code at github.

Additional feature for demo

Call external API

I called an API that returns the fortune using Azure Open AI Chat completion API on Azure Functions using requests package.

Read out ouput wav file

For demoing the voicevox, I use simpleaudio. For running it, I neede to install libasound2 by:

1
sudo apt install -y libasound2-dev

Sample code

A sample code example to call external API(Azure Open AI on Azure Function), text to speech by voicevox, and read out the audio.

github

Reference