OSS版 Siri「Sirius」をインストール
sirius とは
公式サイトでは、以下の通り説明されています。
Sirius is an open-source end-to-end standalone intelligent personal assistant (IPA) service. Sirius receives queries in the form of speech or images and returns results in the form of natural language.
Sirius implements the core functionalities of an IPA including speech recognition, image matching, natural language processing and a question-and-answer system.
翻訳すると、 Sirius は、エンドツーエンド スタンドアロン型の知的パーソナルアシスタント(IPA/intelligent personal assistant)サービスのオープンソース版です。 Sirius は、会話音声の型や画像から、クエリを受け取り、自然言語形式で結果を返します。 Sirius は、音声認識、画像マッチング、自然言語処理と質疑応答システムを含むIPAのコア機能を実装しています。
簡単に言うと、音声入力と画像入力が可能な Siri のオープンソース版ですね。 画像入力をうまくつかえると可能性がひろがりそうです。
使用環境
公式サイトによると、Ubuntu のバージョン 12.04 および 14.04 でのみテストされているようですので、 以下のスペックでインストールしました。
CPU: 1vCPU RAM: 1GB OS: Ubuntu Server 14.04 (x86_64)
インストール
依存パッケージ
依存パッケージは以下の通りとのことです。 - Sphinx (sphinxbase and pocketsphinx) ・・・音声認識 - Kaldi ・・・音声認識 - Protobuf - OpenCV (v2.4.9) ・・・画像認識 - Java (v1.7.0_55)
git のセットアップ
$ sudo apt-get install git
Sirius のセットアップ
まずは、アプリケーションの準備をします。
$ cd /usr/local/ $ sudo mkdir sirius $ sudo chown ubuntu.ubuntu sirius $ git clone https://github.com/claritylab/sirius.git $ cd sirius/sirius-application $ tar xzf question-answer.tar.gz
依存アプリケーションをまとめてインストールします。 すでにインストール済みの場合は、自動でスキップされるようです。
$ sudo ./get-dependencies.sh $ sudo ./get-opencv.sh
公式手順にそって、Kaldi をインストールします。
$ ./get-kaldi.sh
sirius サーバをコンパイルします。
$ ./compile-sirius-servers.sh
自動音声認識(ASR/Automatic Speech Recognition)
自動音声認識を実行するため、以下の3つのバックエンドシステムをサポートしています。 - Kaldi (DNN/HMM 版) - Pocketsphinx - Sphinx4 (GMM/HMM 版)
どうやって切り替えるんだろう..
AWR サーバ
デフォルトでは、Kaldi を使うようで、Kaldi のソースコードを解凍しておかないとエラーが出るので、解凍しておきます。
$ cd /usr/local/sirius/sirius-application/speech-recognition/kaldi $ tar xfz src.tar.gz
ASRサーバを起動します。
$ cd /usr/local/sirius/sirius-application/run-scripts $ ./start-asr-server.sh Starting server on localhost:8081, use <Ctrl-C> to stop ./server.sh: line 12: ..//src/online2bin/online2-wav-nnet2-latgen-faster: No such file or directory
No such file or directory
..気になる..けど一旦無視w
$ ./start-asr-server.sh <kaldi|sphinx4|pocketsphinx> <ip> <port>
こんな感じでIPアドレスやポートが変更と記載されていましたが、うまく動きません..
$ ./start-asr-server.sh kaldi 54.178.143.52 8080 Traceback (most recent call last): File "./start-asr-dnn-server.py", line 74, in <module> server = ThreadedHTTPServer((host, port), Handler) File "/usr/lib/python2.7/SocketServer.py", line 419, in __init__ self.server_bind() File "/usr/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind SocketServer.TCPServer.server_bind(self) File "/usr/lib/python2.7/SocketServer.py", line 430, in server_bind self.socket.bind(self.server_address) File "/usr/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 99] Cannot assign requested address
ASRのテストをします。
$ cd /usr/local/sirius/sirius-application/run-scripts $ ./sirius-asr-test.sh ../inputs/questions/what.is.the.speed.of.light.wav
なんかエラーが出続ける..ということで心が折れましたww
スクリプト読むしかなさそうです..
$ ./start-asr-server.sh Starting server on localhost:8081, use <Ctrl-C> to stop ./server.sh: line 12: ..//src/online2bin/online2-wav-nnet2-latgen-faster: No such file or directory ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 48248) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__ self.handle() File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "./start-asr-dnn-server.py", line 59, in do_POST res = shcin(filename, server_process) File "./start-asr-dnn-server.py", line 26, in shcin server.stdin.write(stdin_data) IOError: [Errno 32] Broken pipe ---------------------------------------- ---------------------------------------- Exception happened during processing of request from ('127.0.0.1', 48249) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 593, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__ self.handle() File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "./start-asr-dnn-server.py", line 59, in do_POST res = shcin(filename, server_process) File "./start-asr-dnn-server.py", line 26, in shcin server.stdin.write(stdin_data) IOError: [Errno 32] Broken pipe
これ以降は、一旦、公式手順からコピーだけ
(未実施です..)
画像マッチング(IM/Image Matching)
Image Matching uses SURF to match query images to a stored database.
In image-matching/ first build and store a database of descriptors in protobuf format where the arguments are the name of the database and the directory containing the images:
$ ./make-db.py landmarks matching/landmarks/db/
To change the database used by the IMM service, change the name in start-imm-server.py.
In run-scripts/, open the IMM server:
$ ./start-imm-server.sh
In a separate terminal, test IMM using:
$ ./sirius-imm-test.sh ../image-matching/matching/landmarks/query/query.jpg
Question-Answering System (QA)
The Question-Answering system uses OpenEphyra and a Wikipedia database stored in Lemur’s Indri format.
Extract the Wikipedia database (after untaring and building question-answer):
$ wget http://web.eecs.umich.edu/~jahausw/download/wiki_indri_index.tar.gz $ tar xzvf wiki_indri_index.tar.gz -C question-answer/
In run-scripts/, open the QA server:
$ ./start-qa-server.sh
In a separate terminal, test QA using:
$ ./sirius-qa-test.sh "what is the speed of light"
Combining Services
It is very easy with Sirius to combine ASR and QA to create the full intelligent personal assistant pipeline. After opening multiple servers using ./start-
$ ./sirius-asr-qa-test.sh ../inputs/real/what.is.the.capital.of.italy.wav