6
7

More than 5 years have passed since last update.

Raspberry pi3B+でjuliusを動かせるようになるまでの覚書き(2019.3.10現在)

Last updated at Posted at 2019-03-10

職場でRaspberry piを使うニーズとして可搬型の音声認識デバイスがありそうなので、プライベート機にセットアップした際の覚書き。
※ネットには解説つきの事例がたくさんあるけれど、記事やバージョンが古かったりして最新版ではちょこちょこ手直ししなければならない箇所があったので注意。

ちなみに音声認識の速度や精度ではGoogle AIYを使った方がいいことは分かり切ってるんだけど、googleのクラウドサーバで処理する都合上「機密管理」にキビシイ日本企業の常で完全スタンドアロンのjuliusを選択した次第。

セットアップの前準備

Raspberry piに音声認識用のマイク付きwebカメラ(USB)を認識させる

USBにwebカメラを刺して

$ lsusb

すると、現在接続されているデバイスが分かる。認識していればOK。

USBマイクの優先順位を設定

$ cat /proc/asound/modules

でオーディオデバイスの優先順位が分かる。

結果
0 snd_bcm2835
1 snd_usb_audio

であればUSBオーディオの優先順位を上げてあげなければならない。

sudo nano /etc/modprobe.d/alsa-base.conf

/etc/modprobe.d/alsa-base.confを書き換えて

/etc/modprobe.d/alsa-base.conf
:
# Keep snd-usb-audio from beeing loaded as first soundcard
#options snd-usb-audio index=-2
options snd-usb-audio index=0
:

にしておく。終わったら、

$ sudo shotdown -r now

でリブート。優先順位を再確認して

$ cat /proc/asound/modules
 0 snd_usb_audio
 1 snd_bcm2835

だったらOK。

ALSAのサウンドドライバをインストール

RaspberryPi3b+の最新カーネルではsnd-pcm-ossモジュールが含まれていないので、あらかじめALSAのサウンドドライバをインストールしておく。

sudo apt-get install osspd-alsa
sudo aptitude install libasound2-dev

ALSADEV設定でデバイスを固定

Juliusを実行する際にカードNo.、デバイスNo.の情報が必要だが、常に同じ設定を使用できるように環境変数として設定しておく。

sudo nano ~/.profile

~/.profileに下記の一文を追加。

.profile
export ALSADEV=hw:0,0

追加後はリブート

juliusのインストール

ソースコードの取得

$ mkdir julius
$ cd julius
$ wget https://github.com/julius-speech/julius/archive/v4.5.tar.gz

ソースコードのコンパイル・インストール

【重要】
./configure --with-mictype=alsaにて上で書いたsnd-pcm-ossモジュールの代わりにALSAを使用するためのオプションを指定するのがミソ。
昔の記事には書いてないけど、raspberry pi3 modelB+ではこれをやっておかないとハマる。

$ tar xvzf v4.5.tar.gz
$ cd julius-4.5
$ ./configure --with-mictype=alsa
$ make
$ sudo make install

julius音声認識パッケージの取得

$ mkdir ~/julius/julius-kit
$ cd ~/julius/julius-kit
$ wget https://github.com/julius-speech/dictation-kit/archive/v4.4.zip
$ unzip dictation-kit-v4.4.zip

juliusの起動・音声認識

$ julius -C ~/julius/julius-kits/dictation-kit-v4.4-linux/main.jconf -C ~/julius/julius-kits/dictation-kit-v4.4-linux/am-gmm.jconf -nostrip

で無事起動して<<< please speak >>>の文字列が表示されれば成功!
終了時はCtrl + Cで終了させること。

参考記事

Raspberry Pi+Juliusで音声を認識する
Raspberry Piで音声認識
raspi最新カーネルでjuliusを動かす

6
7
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
6
7